Unix: Ignore failure to copy file metadata

See #2023476 (Linux error in new trash management)
This commit is contained in:
Kovid Goyal 2023-06-12 16:47:43 +05:30
parent f956f4a207
commit 2e49369657
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -47,7 +47,12 @@ class UnixFileCopier:
for src_path, dest_path in self.copy_map.items():
with suppress(OSError):
os.link(src_path, dest_path, follow_symlinks=False)
shutil.copystat(src_path, dest_path, follow_symlinks=False)
try:
shutil.copystat(src_path, dest_path, follow_symlinks=False)
except OSError:
# Failure to copy metadata is not critical
import traceback
traceback.print_exc()
continue
with suppress(shutil.SameFileError):
shutil.copy2(src_path, dest_path, follow_symlinks=False)