Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9337624
D2473.id8780.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D2473.id8780.diff
View Options
diff --git a/swh/deposit/api/private/deposit_read.py b/swh/deposit/api/private/deposit_read.py
--- a/swh/deposit/api/private/deposit_read.py
+++ b/swh/deposit/api/private/deposit_read.py
@@ -35,35 +35,31 @@
Tuple (directory to clean up, archive path (aggregated or not))
"""
- if len(archive_paths) > 1:
- # need to rebuild one archive from multiple ones
- os.makedirs(extraction_dir, 0o755, exist_ok=True)
- dir_path = tempfile.mkdtemp(prefix='swh.deposit-',
- dir=extraction_dir)
- # root folder to build an aggregated tarball
- aggregated_tarball_rootdir = os.path.join(dir_path, 'aggregate')
- os.makedirs(aggregated_tarball_rootdir, 0o755, exist_ok=True)
-
- # uncompress in a temporary location all archives
- for archive_path in archive_paths:
- tarball.uncompress(archive_path, aggregated_tarball_rootdir)
-
- # Aggregate into one big tarball the multiple smaller ones
- temp_tarpath = tarball.compress(
- aggregated_tarball_rootdir + '.zip',
- nature='zip',
- dirpath_or_files=aggregated_tarball_rootdir)
-
- # can already clean up temporary directory
- shutil.rmtree(aggregated_tarball_rootdir)
-
- try:
- yield temp_tarpath
- finally:
- shutil.rmtree(dir_path)
-
- else: # only 1 archive, no need to do fancy actions (and no cleanup step)
- yield archive_paths[0]
+ # rebuild one zip archive from (possibly) multiple ones
+ os.makedirs(extraction_dir, 0o755, exist_ok=True)
+ dir_path = tempfile.mkdtemp(prefix='swh.deposit-', dir=extraction_dir)
+
+ # root folder to build an aggregated tarball
+ aggregated_tarball_rootdir = os.path.join(dir_path, 'aggregate')
+ os.makedirs(aggregated_tarball_rootdir, 0o755, exist_ok=True)
+
+ # uncompress in a temporary location all archives
+ for archive_path in archive_paths:
+ tarball.uncompress(archive_path, aggregated_tarball_rootdir)
+
+ # Aggregate into one big tarball the multiple smaller ones
+ temp_tarpath = tarball.compress(
+ aggregated_tarball_rootdir + '.zip',
+ nature='zip',
+ dirpath_or_files=aggregated_tarball_rootdir)
+
+ # can already clean up temporary directory
+ shutil.rmtree(aggregated_tarball_rootdir)
+
+ try:
+ yield temp_tarpath
+ finally:
+ shutil.rmtree(dir_path)
class SWHDepositReadArchives(SWHPrivateAPIView, SWHGetDepositAPI,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 3 2025, 8:11 AM (10 w, 17 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218414
Attached To
D2473: Always generate a zip file from uploaded archives
Event Timeline
Log In to Comment