Compare commits

...

2 Commits

Author SHA1 Message Date
Ivan Shapovalov 894cc68e74
Merge aee25c3564 into 7f15c14fc6 2024-04-02 14:09:49 +02:00
Ivan Shapovalov aee25c3564 extract_item: do not delete an existing directory if possible
A pre-existing directory might be a Btrfs subvolume that was created by
the user ahead of time when restoring several nested subvolumes from a
single archive.
2023-10-10 23:42:39 +04:00
1 changed files with 6 additions and 3 deletions

View File

@ -844,10 +844,13 @@ Duration: {0.duration}
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)
except UnicodeEncodeError:
raise self.IncompatibleFilesystemEncodingError(path, sys.getfilesystemencoding()) from None
except OSError: