mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Even more robust handling of temp library during restore
This commit is contained in:
parent
0bc80abeab
commit
2fae9e67c7
@ -99,7 +99,16 @@ class Restore(Thread):
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
with TemporaryDirectory('relib') as tdir:
|
||||
basedir = os.path.dirname(self.src_library_path)
|
||||
try:
|
||||
tdir = TemporaryDirectory('_rlib', dir=basedir)
|
||||
tdir.__enter__()
|
||||
except EnvironmentError:
|
||||
# Incase we dont have permissions to create directories in the
|
||||
# parent folder of the src library
|
||||
tdir = TemporaryDirectory('_rlib')
|
||||
|
||||
with tdir as tdir:
|
||||
self.library_path = tdir
|
||||
self.scan_library()
|
||||
if not self.load_preferences():
|
||||
|
@ -170,7 +170,8 @@ class TemporaryDirectory(object):
|
||||
self.keep = keep
|
||||
|
||||
def __enter__(self):
|
||||
self.tdir = _make_dir(self.suffix, self.prefix, self.dir)
|
||||
if not hasattr(self, 'tdir'):
|
||||
self.tdir = _make_dir(self.suffix, self.prefix, self.dir)
|
||||
return self.tdir
|
||||
|
||||
def __exit__(self, *args):
|
||||
|
Loading…
x
Reference in New Issue
Block a user