-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
extract_item: do not delete an existing directory if possible #7866
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -858,10 +858,13 @@ def same_item(item, st): | |
st = os.stat(path, follow_symlinks=False) | ||
if continue_extraction and same_item(item, st): | ||
return # done! we already have fully extracted this file in a previous run. | ||
elif stat.S_ISDIR(st.st_mode): | ||
os.rmdir(path) | ||
else: | ||
# remove anything that is not a directory | ||
if not stat.S_ISDIR(st.st_mode): | ||
os.unlink(path) | ||
# only remove a directory if it is conflicting | ||
# preserve existing directories because they might be subvolumes | ||
elif not stat.S_ISDIR(item.mode): | ||
os.rmdir(path) | ||
Comment on lines
+866
to
+867
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's rather unclear still whether the resulting directory after extraction will be correct (== as in the archive) in all cases:
The existing directory could have some metadata set already, but the resulting directory must be exactly what we have in the archived item, not a mix up of fs item and archived item. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code that makes sure about this could be also useful later if we implement extracting into a non-empty directory (for more than the simplest cases, like the already implemented "continue an extraction"). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, thinking about it... we currently more or less require extracting into an empty dir (exception: that "continue extraction" feature). we could also require that if there is any pre-existing directory inside the extraction directory, it must not have any special attrs set. |
||
except UnicodeEncodeError: | ||
raise self.IncompatibleFilesystemEncodingError(path, sys.getfilesystemencoding()) from None | ||
except OSError: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is subvolumes a feature implemented by other fs than btrfs?
if not, maybe we better call it "btrfs subvolumes" here, so it is more clear.