From 30c4d00d9b81e922ec21537347ae504b855a7806 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Nov 2015 20:43:41 +0530 Subject: [PATCH] Fix #1519855 [restore database without metadata.db present in directory fails](https://bugs.launchpad.net/calibre/+bug/1519855) --- src/calibre/db/restore.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/calibre/db/restore.py b/src/calibre/db/restore.py index c6d3f606c5..07ada5ee68 100644 --- a/src/calibre/db/restore.py +++ b/src/calibre/db/restore.py @@ -269,10 +269,11 @@ class Restore(Thread): save_path = self.olddb = os.path.splitext(dbpath)[0]+'_pre_restore.db' if os.path.exists(save_path): os.remove(save_path) - try: - os.rename(dbpath, save_path) - except EnvironmentError: - time.sleep(30) # Wait a little for dropbox or the antivirus or whatever to release the file - shutil.copyfile(dbpath, save_path) - os.remove(dbpath) + if os.path.exists(dbpath): + try: + os.rename(dbpath, save_path) + except EnvironmentError: + time.sleep(30) # Wait a little for dropbox or the antivirus or whatever to release the file + shutil.copyfile(dbpath, save_path) + os.remove(dbpath) shutil.copyfile(ndbpath, dbpath)