Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync_tree sometimes fails to copy the read-only attribute on Windows #680

Open
sebastianpoeplau opened this issue Feb 13, 2024 · 1 comment

Comments

@sebastianpoeplau
Copy link

In some cases, e3.fs.sync_tree fails to synchronize the Windows read-only attribute on files. You can reproduce the problem using the following script:

from e3.fs import sync_tree
from e3.os.fs import chmod

chmod("a-wx", "in/foo.txt")
sync_tree("in", "out", delete=True)

(It doesn't seem to matter whether delete is True or False.)

This is how I used the script:

poeplau@PAWNEE ~/code/sync_tree
$ mkdir in out

poeplau@PAWNEE ~/code/sync_tree
$ touch {in,out}/foo.txt

poeplau@PAWNEE ~/code/sync_tree
$ ll in out
in:
total 0
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 .
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 ..
-rw-rw-r--+ 1 poeplau None 0 Feb 13 12:14 foo.txt

out:
total 0
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 .
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 ..
-rw-rw-r--+ 1 poeplau None 0 Feb 13 12:14 foo.txt

poeplau@PAWNEE ~/code/sync_tree
$ python sync_tree_test.py 

poeplau@PAWNEE ~/code/sync_tree
$ ll in out
in:
total 0
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 .
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 ..
-r--r--r--+ 1 poeplau None 0 Feb 13 12:14 foo.txt

out:
total 0
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 .
drwxrwxr-x+ 1 poeplau None 0 Feb 13 12:14 ..
-rw-rw-r--+ 1 poeplau None 0 Feb 13 12:14 foo.txt

Note how out/foo.txt is still writable after the call to sync_tree. Windows Explorer confirms that the read-only attribute isn't set.

@sebastianpoeplau
Copy link
Author

Here's the output of attrib before and after running the script, in both directories.

# Before
# in
A            C:\home\poeplau\code\sync_tree\in\foo.txt
# out
A            C:\home\poeplau\code\sync_tree\out\foo.txt

# After
# in
A    R       C:\home\poeplau\code\sync_tree\in\foo.txt
# out
A            C:\home\poeplau\code\sync_tree\out\foo.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant