Copy database path to cache and delete after importing

This commit is contained in:
JonnyWong16 2021-03-29 00:04:10 -07:00
parent 0f2dbf2c94
commit 5ca5f24a66
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 12 additions and 2 deletions

View file

@ -211,6 +211,9 @@ def import_tautulli_db(database=None, method=None, backup=False):
logger.info("Tautulli Database :: Tautulli database import complete.") logger.info("Tautulli Database :: Tautulli database import complete.")
set_is_importing(False) set_is_importing(False)
logger.info("Tautulli Database :: Deleting cached database: %s", database)
os.remove(database)
def integrity_check(): def integrity_check():
monitor_db = MonitorDatabase() monitor_db = MonitorDatabase()

View file

@ -3914,9 +3914,16 @@ class WebInterface(object):
if not app: if not app:
return {'result': 'error', 'message': 'No app specified for import'} return {'result': 'error', 'message': 'No app specified for import'}
if database_file: if database_path:
database_file_name = os.path.basename(database_path)
database_cache_path = os.path.join(plexpy.CONFIG.CACHE_DIR, database_file_name + '.import.db')
logger.info("Received database file '%s' for import. Saving to cache: %s",
database_file_name, database_cache_path)
database_path = shutil.copyfile(database_path, database_cache_path)
elif database_file:
database_path = os.path.join(plexpy.CONFIG.CACHE_DIR, database_file.filename + '.import.db') database_path = os.path.join(plexpy.CONFIG.CACHE_DIR, database_file.filename + '.import.db')
logger.info("Received database file '%s' for import. Saving to cache '%s'.", logger.info("Received database file '%s' for import. Saving to cache: %s",
database_file.filename, database_path) database_file.filename, database_path)
with open(database_path, 'wb') as f: with open(database_path, 'wb') as f:
while True: while True: