Skip to content

Commit

Permalink
Fix for package managers storing files in read-only
Browse files Browse the repository at this point in the history
update write permissions via in-built python functions

fix: do not give exec permissions

fix whatever typo is was
  • Loading branch information
bzizou authored and asl committed Jul 2, 2024
1 parent 60ad35e commit af1f756
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/projects/spades/pipeline/spades_pipeline/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,20 @@ def is_int(value):
return False


def add_user_write_permission_recursive(path):
s = os.stat(path)
os.chmod(path, s.st_mode | stat.S_IWUSR | stat.S_IRUSR)
for root, dirs, files in os.walk(path):
for d in dirs:
d = os.path.join(root, d)
s = os.stat(d)
os.chmod(d, s.st_mode | stat.S_IWUSR | stat.S_IRUSR)
for f in files:
f = os.path.join(root, f)
s = os.stat(d)
os.chmod(f, s.st_mode | stat.S_IWUSR | stat.S_IRUSR)


# shutil.copyfile does not copy any metadata (time and permission), so one
# cannot expect preserve_mode = False and preserve_times = True to work.
def copy_tree(src, dst, preserve_times=True, preserve_mode=True):
Expand All @@ -938,10 +952,12 @@ def copy_tree(src, dst, preserve_times=True, preserve_mode=True):

# shutil.copytree preserves the timestamp, so we must update it afterwards.
shutil.copytree(src, dst, copy_function = copy_fn)
if not preserve_mode:
add_user_write_permission_recursive(dst)

if not preserve_times:
for dirpath, _, filenames in os.walk(dst):
os.utime(dirpath, None)
for file in filenames:
os.utime(os.path.join(dirpath, file), None)

0 comments on commit af1f756

Please sign in to comment.