Edit Book: Use the cache directory rather than the temp directory to store working files. Hopefully prevents temp file cleaners from destroying books. See #1740460 (Edit Book feature results in error after previously editing successfully)

This commit is contained in:
Kovid Goyal 2017-12-29 11:25:20 +05:30
parent 2ea7fd0c52
commit 0c01357f8b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -296,7 +296,9 @@ class Boss(QObject):
self.container_count = -1 self.container_count = -1
if self.tdir: if self.tdir:
shutil.rmtree(self.tdir, ignore_errors=True) shutil.rmtree(self.tdir, ignore_errors=True)
self.tdir = PersistentTemporaryDirectory() # We use the cache dir rather than the temporary dir to try and prevent
# temp file cleaners from nuking ebooks. See https://bugs.launchpad.net/bugs/1740460
self.tdir = PersistentTemporaryDirectory(prefix='calibre-ew-', dir=cache_dir())
self._edit_file_on_open = edit_file self._edit_file_on_open = edit_file
self._clear_notify_data = clear_notify_data self._clear_notify_data = clear_notify_data
self.gui.blocking_job('open_book', _('Opening book, please wait...'), self.book_opened, get_container, path, tdir=self.mkdtemp()) self.gui.blocking_job('open_book', _('Opening book, please wait...'), self.book_opened, get_container, path, tdir=self.mkdtemp())