mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix errors caused by .DS_Store files inserted into the .caltrash directory on macOS if the user happens to open .caltrash in Finder. Fixes #2037237 [NotADirectoryError when merging books on MacOS](https://bugs.launchpad.net/calibre/+bug/2037237)
This commit is contained in:
parent
3d045fb230
commit
7bde152ed3
@ -2040,13 +2040,14 @@ class DB:
|
||||
for base in ('b', 'f'):
|
||||
base = os.path.join(self.trash_dir, base)
|
||||
for x in os.scandir(base):
|
||||
try:
|
||||
st = x.stat(follow_symlinks=False)
|
||||
mtime = st.st_mtime
|
||||
except OSError:
|
||||
mtime = 0
|
||||
if mtime + expire_age_in_seconds <= now or expire_age_in_seconds <= 0:
|
||||
removals.append(x.path)
|
||||
if x.is_dir(follow_symlinks=False):
|
||||
try:
|
||||
st = x.stat(follow_symlinks=False)
|
||||
mtime = st.st_mtime
|
||||
except OSError:
|
||||
mtime = 0
|
||||
if mtime + expire_age_in_seconds <= now or expire_age_in_seconds <= 0:
|
||||
removals.append(x.path)
|
||||
for x in removals:
|
||||
try:
|
||||
rmtree_with_retry(x)
|
||||
|
Loading…
x
Reference in New Issue
Block a user