You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve file permissions in fakefs after add_real_file #1119
Describe the bug
Suppose I have a real file /usr/bin/env, owned by root:root, with permissions 0755.
If I copy this file into a fake filesystem the user and group are preserved, but the permissions are changed to 0444.
How To Reproduce
Note: This assumes you are on a *nix system with an executable file /usr/bin/env on your real filesystem.
If not, substitute any other file owned by root with permissions 0755.
Ok, I completly forgot that this is expected behavior. By default, files from the real filesystem are mapped as read-only. From the documentation:
The access to the files is by default read-only, but even if you add them using read_only=False, the files are written only in the fake system (e.g. in memory).
Replacing fs.add_real_file(file) with fs.add_real_file(file, read_only=False) should give you the wanted behavior.
Please check if this is sufficient for you.
Activity
mrbean-bremen commentedon Feb 18, 2025
Thanks, I will have a look!
mrbean-bremen commentedon Feb 18, 2025
Ok, I completly forgot that this is expected behavior. By default, files from the real filesystem are mapped as read-only. From the documentation:
Replacing
fs.add_real_file(file)withfs.add_real_file(file, read_only=False)should give you the wanted behavior.Please check if this is sufficient for you.
mrbean-bremen commentedon Feb 28, 2025
Converting this to a discussion issue.
Or trying to... seems not to work at the moment.