Windows: Generate catalog: Workaround for systems where a broken antivirus or similar holds open files in the catalog library causing a permission denied error. Fixes #2115084 [Create Catalog fails](https://bugs.launchpad.net/calibre/+bug/2115084)

This commit is contained in:
Kovid Goyal 2025-06-21 08:09:27 +05:30
parent ea7e12d0f1
commit fb4654bd91
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -5,6 +5,7 @@ __docformat__ = 'restructuredtext en'
import os
from optparse import OptionParser
from calibre.constants import iswindows
from calibre.customize.conversion import DummyReporter, OptionRecommendation
from calibre.customize.ui import plugin_for_catalog_format
from calibre.ebooks.conversion.plumber import Plumber
@ -80,6 +81,10 @@ def gui_catalog(library_path, temp_db_path, fmt, title, dbspec, ids, out_file_na
plugin = plugin_for_catalog_format(fmt)
return plugin.run(out_file_name, opts, db, notification=notification)
finally:
import shutil
db.close()
shutil.rmtree(os.path.dirname(temp_db_path))
from calibre.db.backend import rmtree_with_retry
try:
rmtree_with_retry(temp_db_path)
except PermissionError:
if not iswindows: # probably some antivirus holding a file open, the folder will be deleted on exit anyway
raise