mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add some exception handling code for when the preferences backup file doesn't exist.
This commit is contained in:
parent
4205c7b8a1
commit
6fe358ed3e
@ -115,12 +115,18 @@ class Restore(Thread):
|
|||||||
self.progress_callback('Starting restore preferences', 0)
|
self.progress_callback('Starting restore preferences', 0)
|
||||||
dbpath = os.path.join(self.src_library_path, 'metadata_db_prefs.json')
|
dbpath = os.path.join(self.src_library_path, 'metadata_db_prefs.json')
|
||||||
ndbpath = os.path.join(self.library_path, 'metadata_db_prefs.json')
|
ndbpath = os.path.join(self.library_path, 'metadata_db_prefs.json')
|
||||||
shutil.copyfile(dbpath, ndbpath)
|
if not os.path.exists(dbpath):
|
||||||
db = RestoreDatabase(self.library_path)
|
self.progress_callback('Cannot restore preferences. Backup file not found.', 1)
|
||||||
db.prefs.read_serialized(self.library_path)
|
return
|
||||||
db.commit()
|
try:
|
||||||
db.conn.close()
|
shutil.copyfile(dbpath, ndbpath)
|
||||||
self.progress_callback('Finished restore preferences', 1)
|
db = RestoreDatabase(self.library_path)
|
||||||
|
db.prefs.read_serialized(self.library_path)
|
||||||
|
db.commit()
|
||||||
|
db.conn.close()
|
||||||
|
self.progress_callback('Finished restore preferences', 1)
|
||||||
|
except:
|
||||||
|
self.progress_callback('Restoring preferences failed', 1)
|
||||||
|
|
||||||
def scan_library(self):
|
def scan_library(self):
|
||||||
for dirpath, dirnames, filenames in os.walk(self.src_library_path):
|
for dirpath, dirnames, filenames in os.walk(self.src_library_path):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user