mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-16 13:46:57 +01:00
newdb: Fix deleting empty records leaving behind a temp dir
This commit is contained in:
parent
986f8b467e
commit
c2a572faa7
1 changed files with 8 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ def delete_books(self, paths, library_path):
|
|||
self.queue_paths(tdir, paths, delete_empty_parent=True)
|
||||
|
||||
def queue_paths(self, tdir, paths, delete_empty_parent=True):
|
||||
queued = False
|
||||
for path in paths:
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
|
|
@ -65,6 +66,13 @@ def queue_paths(self, tdir, paths, delete_empty_parent=True):
|
|||
if e.errno != errno.ENOTEMPTY:
|
||||
raise
|
||||
self.requests.put(os.path.join(tdir, os.path.basename(path)))
|
||||
queued = True
|
||||
if not queued:
|
||||
try:
|
||||
os.rmdir(tdir)
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOTEMPTY:
|
||||
raise
|
||||
|
||||
def delete_files(self, paths, library_path):
|
||||
tdir = self.create_staging(library_path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue