launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #32144
[Merge] ~ruinedyourlife/launchpad:fix-sourcecraft-build-output-fetch-service-files into launchpad:master
Quentin Debhi has proposed merging ~ruinedyourlife/launchpad:fix-sourcecraft-build-output-fetch-service-files into launchpad:master.
Commit message:
Upload all outputted files
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ruinedyourlife/launchpad/+git/launchpad/+merge/480189
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ruinedyourlife/launchpad:fix-sourcecraft-build-output-fetch-service-files into launchpad:master.
diff --git a/lib/lp/archiveuploader/craftrecipeupload.py b/lib/lp/archiveuploader/craftrecipeupload.py
index 152a469..d19f87e 100644
--- a/lib/lp/archiveuploader/craftrecipeupload.py
+++ b/lib/lp/archiveuploader/craftrecipeupload.py
@@ -42,18 +42,41 @@ class CraftRecipeUpload:
"""Process this upload, loading it into the database."""
self.logger.debug("Beginning processing.")
- # Find all .tar.xz files in subdirectories
+ # Find all files in subdirectories
upload_path = Path(self.upload_path)
- craft_paths = list(upload_path.rglob("*.tar.xz"))
-
- # Skip files directly in upload_path
- craft_paths = [p for p in craft_paths if p.parent != upload_path]
+ found_craft = False
+ craft_paths = []
+ other_files = []
+
+ # Collect all files, separating tar.xz from others
+ for path in upload_path.rglob("*"):
+ if path.parent == upload_path:
+ # Skip files directly in upload_path
+ continue
+ if path.is_file():
+ if path.name.endswith(".tar.xz"):
+ found_craft = True
+ craft_paths.append(path)
+ else:
+ other_files.append(path)
- if not craft_paths:
+ if not found_craft:
raise UploadError("Build did not produce any craft files.")
+ # Upload all non-tar.xz files first
+ for path in sorted(other_files):
+ with open(path, "rb") as file:
+ libraryfile = self.librarian.create(
+ path.name,
+ os.stat(path).st_size,
+ file,
+ filenameToContentType(str(path)),
+ restricted=build.is_private,
+ )
+ build.addFile(libraryfile)
+
+ # Process tar.xz files
for craft_path in sorted(craft_paths):
- # Check if archive contains .crate files
with tempfile.TemporaryDirectory() as tmpdir:
with tarfile.open(craft_path, "r:xz") as tar:
tar.extractall(path=tmpdir)
@@ -63,7 +86,7 @@ class CraftRecipeUpload:
metadata_path = Path(tmpdir) / "metadata.yaml"
if crate_files and metadata_path.exists():
- # If we found a crate file and metadata, upload it
+ # If we found a crate file and metadata, upload those
try:
metadata = yaml.safe_load(metadata_path.read_text())
crate_name = metadata.get("name")
@@ -78,9 +101,8 @@ class CraftRecipeUpload:
"Failed to parse metadata.yaml: %s", e
)
- crate_path = crate_files[
- 0
- ] # Take the first (and should be only) crate file
+ # Upload the crate file
+ crate_path = crate_files[0]
with open(crate_path, "rb") as file:
libraryfile = self.librarian.create(
os.path.basename(str(crate_path)),
@@ -90,6 +112,17 @@ class CraftRecipeUpload:
restricted=build.is_private,
)
build.addFile(libraryfile)
+
+ # Upload metadata.yaml
+ with open(metadata_path, "rb") as file:
+ libraryfile = self.librarian.create(
+ "metadata.yaml",
+ os.stat(metadata_path).st_size,
+ file,
+ filenameToContentType(str(metadata_path)),
+ restricted=build.is_private,
+ )
+ build.addFile(libraryfile)
else:
# If no crate file found, upload the original archive
self.logger.debug(
Follow ups