Fix #1519855 [restore database without metadata.db present in directory fails](https://bugs.launchpad.net/calibre/+bug/1519855)

This commit is contained in:
Kovid Goyal 2015-11-25 20:43:41 +05:30
parent c63d75bae4
commit 30c4d00d9b

View File

@ -269,10 +269,11 @@ class Restore(Thread):
save_path = self.olddb = os.path.splitext(dbpath)[0]+'_pre_restore.db' save_path = self.olddb = os.path.splitext(dbpath)[0]+'_pre_restore.db'
if os.path.exists(save_path): if os.path.exists(save_path):
os.remove(save_path) os.remove(save_path)
try: if os.path.exists(dbpath):
os.rename(dbpath, save_path) try:
except EnvironmentError: os.rename(dbpath, save_path)
time.sleep(30) # Wait a little for dropbox or the antivirus or whatever to release the file except EnvironmentError:
shutil.copyfile(dbpath, save_path) time.sleep(30) # Wait a little for dropbox or the antivirus or whatever to release the file
os.remove(dbpath) shutil.copyfile(dbpath, save_path)
os.remove(dbpath)
shutil.copyfile(ndbpath, dbpath) shutil.copyfile(ndbpath, dbpath)