[buildinfo.debian.net] 05/07: Store files directly onto S3.

Chris Lamb chris at chris-lamb.co.uk
Sat Jan 28 21:58:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository buildinfo.debian.net.

commit 61b04f83c036580f2bb1d97655c980e00fd5d865
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Jan 29 10:33:58 2017 +1300

    Store files directly onto S3.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 bidb/api/utils.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/bidb/api/utils.py b/bidb/api/utils.py
index 4e75f37..7fef3a5 100644
--- a/bidb/api/utils.py
+++ b/bidb/api/utils.py
@@ -5,6 +5,8 @@ from debian import deb822
 from dateutil.parser import parse
 
 from django.db import transaction, IntegrityError
+from django.core.files.base import ContentFile
+from django.core.files.storage import default_storage
 
 from bidb.keys.models import Key
 from bidb.packages.models import Source, Architecture, Binary
@@ -47,11 +49,17 @@ def parse_submission(request):
     ## Check whether .buildinfo already exists ################################
 
     def create_submission(buildinfo):
-        return buildinfo.submissions.create(
+        submission = buildinfo.submissions.create(
             key=Key.objects.get_or_create(uid=uid)[0],
-            raw_text=raw_text,
         )
 
+        default_storage.save(
+            submission.get_storage_name(),
+            ContentFile(raw_text),
+        )
+
+        return submission
+
     sha1 = hashlib.sha1(raw_text_gpg_stripped.encode('utf-8')).hexdigest()
     try:
         # Already exists; just attach a new Submission instance
@@ -72,7 +80,6 @@ def parse_submission(request):
 
     buildinfo = Buildinfo.objects.create(
         sha1=sha1,
-        raw_text=raw_text_gpg_stripped,
 
         source=get_or_create(Source, 'Source'),
         architecture=get_or_create(Architecture, 'Architecture'),
@@ -86,6 +93,11 @@ def parse_submission(request):
         environment=data.get('Environment', ''),
     )
 
+    default_storage.save(
+        buildinfo.get_storage_name(),
+        ContentFile(raw_text_gpg_stripped),
+    )
+
     ## Parse binaries #########################################################
 
     try:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/buildinfo.debian.net.git



More information about the Reproducible-commits mailing list