Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123379
D8660.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
D8660.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
@@ -179,8 +179,11 @@
Args:
path: the path under which permissions should be normalized
"""
- for dirpath, _, fnames in os.walk(path):
- os.chmod(dirpath, 0o0755)
+ os.chmod(path, 0o0755)
+ for dirpath, dnames, fnames in os.walk(path):
+ for dname in dnames:
+ dpath = os.path.join(dirpath, dname)
+ os.chmod(dpath, 0o0755)
for fname in fnames:
fpath = os.path.join(dirpath, fname)
if not os.path.islink(fpath):
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
@@ -6,6 +6,7 @@
import hashlib
import os
import shutil
+import stat
import pytest
@@ -186,16 +187,26 @@
file_path.touch()
file_path.chmod(perms)
+ # add directory without any permission
+ dir_path = tmp_path / "dir"
+ dir_path.mkdir(mode=stat.S_IFDIR)
+
for file in tmp_path.iterdir():
- assert file.stat().st_mode == 0o100000 | int(file.name)
+ if file.is_dir():
+ assert file.stat().st_mode == stat.S_IFDIR
+ else:
+ assert file.stat().st_mode == 0o100000 | int(file.name)
tarball.normalize_permissions(str(tmp_path))
for file in tmp_path.iterdir():
- if int(file.name) & 0o100: # original file was executable for its owner
- assert file.stat().st_mode == 0o100755
+ if file.is_dir():
+ assert file.stat().st_mode == stat.S_IFDIR + 0o000755
else:
- assert file.stat().st_mode == 0o100644
+ if int(file.name) & 0o100: # original file was executable for its owner
+ assert file.stat().st_mode == 0o100755
+ else:
+ assert file.stat().st_mode == 0o100644
def test_unpcompress_zip_imploded(tmp_path, datadir):
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 6:58 AM (12 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221247
Attached To
D8660: tarball: Fix also directory permissions in normalize_permissions
Event Timeline
Log In to Comment