Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696126
D5857.id20964.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D5857.id20964.diff
View Options
diff --git a/swh/core/tarball.py b/swh/core/tarball.py
--- a/swh/core/tarball.py
+++ b/swh/core/tarball.py
@@ -81,13 +81,15 @@
Args:
tarpath: path to tarball to uncompress
- dest: the destination folder where to uncompress the tarball
+ dest: the destination folder where to uncompress the tarball,
+ it will be created if it does not exist
Raises:
ValueError when a problem occurs during unpacking
"""
try:
+ os.makedirs(dest, exist_ok=True)
shutil.unpack_archive(tarpath, extract_dir=dest)
except shutil.ReadError as e:
raise ValueError(f"Problem during unpacking {tarpath}. Reason: {e}")
diff --git a/swh/core/tests/test_tarball.py b/swh/core/tests/test_tarball.py
--- a/swh/core/tests/test_tarball.py
+++ b/swh/core/tests/test_tarball.py
@@ -127,21 +127,6 @@
tarball.uncompress(tarpath, tmp_path)
-def test_uncompress_tar_failure2(tmp_path, datadir):
- """Unpack Existent tarball into an inexistent folder should fail
-
- """
- filename = "groff-1.02.tar.Z"
- tarpath = os.path.join(datadir, "archives", filename)
-
- assert os.path.exists(tarpath)
-
- extract_dir = os.path.join(tmp_path, "dir", "inexistent")
-
- with pytest.raises(ValueError, match=f"Problem during unpacking {tarpath}"):
- tarball.uncompress(tarpath, extract_dir)
-
-
def test_uncompress_tar(tmp_path, datadir):
"""Unpack supported tarball into an existent folder should be ok
@@ -152,7 +137,6 @@
assert os.path.exists(tarpath)
extract_dir = os.path.join(tmp_path, filename)
- os.makedirs(extract_dir, exist_ok=True)
tarball.uncompress(tarpath, extract_dir)
@@ -234,7 +218,6 @@
assert os.path.exists(zippath)
extract_dir = os.path.join(tmp_path, filename)
- os.makedirs(extract_dir, exist_ok=True)
tarball.uncompress(zippath, extract_dir)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Aug 17, 7:01 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217029
Attached To
D5857: tarball/uncompress: Ensure destination folder exists before unpacking
Event Timeline
Log In to Comment