Prevent error on windows during upload and during rename of metadata.db in combinstion with gdrive

pull/519/merge
OzzieIsaacs 6 years ago
parent 76d8cbdf57
commit fbe2f5384b

@ -1626,7 +1626,8 @@ def on_received_watch_confirmation():
app.logger.info('Backing up existing and downloading updated metadata.db') app.logger.info('Backing up existing and downloading updated metadata.db')
gdriveutils.downloadFile(Gdrive.Instance().drive, None, "metadata.db", os.path.join(tmpDir, "tmp_metadata.db")) gdriveutils.downloadFile(Gdrive.Instance().drive, None, "metadata.db", os.path.join(tmpDir, "tmp_metadata.db"))
app.logger.info('Setting up new DB') app.logger.info('Setting up new DB')
os.rename(os.path.join(tmpDir, "tmp_metadata.db"), dbpath) # prevent error on windows, as os.rename does on exisiting files
shutil.move(os.path.join(tmpDir, "tmp_metadata.db"), dbpath)
db.setup_db() db.setup_db()
except Exception as e: except Exception as e:
app.logger.exception(e) app.logger.exception(e)
@ -3351,8 +3352,8 @@ def upload():
input_tags = tags.split(',') input_tags = tags.split(',')
input_tags = list(map(lambda it: it.strip(), input_tags)) input_tags = list(map(lambda it: it.strip(), input_tags))
if input_tags[0] !="":
modify_database_object(input_tags, db_book.tags, db.Tags, db.session, 'tags') modify_database_object(input_tags, db_book.tags, db.Tags, db.session, 'tags')
if db_language is not None: # display Full name instead of iso639.part3 if db_language is not None: # display Full name instead of iso639.part3
db_book.languages[0].language_name = _(meta.languages) db_book.languages[0].language_name = _(meta.languages)
author_names = [] author_names = []

Loading…
Cancel
Save