Use the cache dir for temp files created by auto-add

Idiotic windows temp file cleaners.
This commit is contained in:
Kovid Goyal 2018-03-01 18:03:33 +05:30
parent 4db8ce5f81
commit 55ad9a3c97
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -14,11 +14,11 @@ from future_builtins import map
from PyQt5.Qt import (QFileSystemWatcher, QObject, Qt, pyqtSignal, QTimer, QApplication, QCursor)
from calibre import prints
from calibre.ptempfile import PersistentTemporaryDirectory
from calibre.db.adding import filter_filename, compile_rule
from calibre.ebooks import BOOK_EXTENSIONS
from calibre.gui2 import gprefs
from calibre.gui2.dialogs.duplicates import DuplicatesQuestion
from calibre.utils.tdir_in_cache import tdir_in_cache
AUTO_ADDED = frozenset(BOOK_EXTENSIONS) - {'pdr', 'mbp', 'tan'}
@ -69,17 +69,20 @@ class Worker(Thread):
return allowed
def run(self):
self.tdir = PersistentTemporaryDirectory('_auto_adder')
while self.keep_running:
self.wake_up.wait()
self.wake_up.clear()
if not self.keep_running:
break
try:
self.auto_add()
except:
import traceback
traceback.print_exc()
self.tdir = tdir_in_cache('aa')
try:
while self.keep_running:
self.wake_up.wait()
self.wake_up.clear()
if not self.keep_running:
break
try:
self.auto_add()
except:
import traceback
traceback.print_exc()
finally:
shutil.rmtree(self.tdir, ignore_errors=True)
def auto_add(self):
from calibre.utils.ipc.simple_worker import fork_job, WorkerError