← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ilasc/launchpad:store-dpkg-yaml-on-snapbuild into launchpad:master

 

Ioana Lasc has proposed merging ~ilasc/launchpad:store-dpkg-yaml-on-snapbuild into launchpad:master.

Commit message:
Store dpkg.yaml on SnapBuild

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/408629
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:store-dpkg-yaml-on-snapbuild into launchpad:master.
diff --git a/lib/lp/archiveuploader/snapupload.py b/lib/lp/archiveuploader/snapupload.py
index a2b4059..9642d31 100644
--- a/lib/lp/archiveuploader/snapupload.py
+++ b/lib/lp/archiveuploader/snapupload.py
@@ -52,11 +52,12 @@ class SnapUpload:
             raise UploadError("Build did not produce any snap packages.")
 
         for snap_path in snap_paths:
-            libraryfile = self.librarian.create(
-                os.path.basename(snap_path), os.stat(snap_path).st_size,
-                open(snap_path, "rb"),
-                filenameToContentType(snap_path),
-                restricted=build.is_private)
+            with open(snap_path, 'rb') as file_to_upload:
+                libraryfile = self.librarian.create(
+                    os.path.basename(snap_path), os.stat(snap_path).st_size,
+                    file_to_upload,
+                    filenameToContentType(snap_path),
+                    restricted=build.is_private)
             build.addFile(libraryfile)
 
         # The master verifies the status to confirm successful upload.
diff --git a/lib/lp/archiveuploader/tests/test_snapupload.py b/lib/lp/archiveuploader/tests/test_snapupload.py
index ffb5997..0f216b4 100644
--- a/lib/lp/archiveuploader/tests/test_snapupload.py
+++ b/lib/lp/archiveuploader/tests/test_snapupload.py
@@ -56,6 +56,8 @@ class TestSnapBuildUploads(TestUploadProcessorBase):
         write_file(os.path.join(upload_dir, "wget_0_all.snap"), b"snap")
         write_file(
             os.path.join(upload_dir, "wget_0_all.manifest"), b"manifest")
+        write_file(os.path.join(upload_dir, "wget_0_all.dpkg.yaml"),
+                   b"yaml file")
         handler = UploadHandler.forProcessor(
             self.uploadprocessor, self.incoming_folder, "test", self.build)
         result = handler.processSnap(self.log)
@@ -64,6 +66,7 @@ class TestSnapBuildUploads(TestUploadProcessorBase):
             "Snap upload failed\nGot: %s" % self.log.getLogBuffer())
         self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
         self.assertTrue(self.build.verifySuccessfulUpload())
+        self.assertEqual(3, len(list(self.build.getFiles())))
 
     def test_requires_snap(self):
         # The upload processor fails if the upload does not contain any
@@ -99,6 +102,8 @@ class TestSnapBuildUploads(TestUploadProcessorBase):
         upload_dir = os.path.join(
             self.incoming_folder, "test", str(self.build.id), "ubuntu")
         write_file(os.path.join(upload_dir, "wget_0_all.snap"), b"snap")
+        write_file(os.path.join(upload_dir, "wget_0_all.dpkg.yaml"),
+                   b"yaml file")
         handler = UploadHandler.forProcessor(
             self.uploadprocessor, self.incoming_folder, "test", self.build)
         result = handler.processSnap(self.log)
@@ -108,3 +113,5 @@ class TestSnapBuildUploads(TestUploadProcessorBase):
         self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
         self.assertTrue(self.build.verifySuccessfulUpload())
         self.assertEqual(1, len(list(self.build.store_upload_jobs)))
+        self.assertEqual(2, len(list(self.build.getFiles())))
+

Follow ups