Page MenuHomeSoftware Heritage

D8660.id31290.diff
No OneTemporary

D8660.id31290.diff

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

Mime Type
text/plain
Expires
Thu, Dec 19, 8:45 AM (15 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221247

Event Timeline