From 54a085c5b23ab1bc1b2f3a51cf40666115d00deb Mon Sep 17 00:00:00 2001 From: krateng Date: Fri, 31 Mar 2023 21:06:54 +0200 Subject: [PATCH] Added startup upgrade task for album parsing --- maloja/database/__init__.py | 1 + maloja/database/exceptions.py | 2 +- maloja/upgrade.py | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index 4549c9d..fcdb861 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -619,6 +619,7 @@ def start_db(): # Upgrade database from .. import upgrade upgrade.upgrade_db(sqldb.add_scrobbles) + upgrade.parse_old_albums() # Load temporary tables from . import associated diff --git a/maloja/database/exceptions.py b/maloja/database/exceptions.py index 0d4fce4..4a98d5c 100644 --- a/maloja/database/exceptions.py +++ b/maloja/database/exceptions.py @@ -16,7 +16,7 @@ class DatabaseNotBuilt(HTTPError): def __init__(self): super().__init__( status=503, - body="The Maloja Database is being upgraded to Version 3. This could take quite a long time! (~ 2-5 minutes per 10 000 scrobbles)", + body="The Maloja Database is being upgraded to support new Maloja features. This could take a while.", headers={"Retry-After":120} ) diff --git a/maloja/upgrade.py b/maloja/upgrade.py index 67d1176..a4f20cc 100644 --- a/maloja/upgrade.py +++ b/maloja/upgrade.py @@ -11,6 +11,9 @@ from .pkg_global.conf import data_dir, dir_settings from .apis import _apikeys +from .database.sqldb import get_maloja_info, set_maloja_info + + # Dealing with old style tsv files - these should be phased out everywhere def read_tsvs(path,types): result = [] @@ -40,7 +43,7 @@ def upgrade_apikeys(): except Exception: pass - +# v2 to v3 iupgrade def upgrade_db(callback_add_scrobbles): oldfolder = os.path.join(dir_settings['state'],"scrobbles") @@ -88,3 +91,13 @@ def upgrade_db(callback_add_scrobbles): callback_add_scrobbles(scrobblelist) os.rename(os.path.join(oldfolder,sf),os.path.join(newfolder,sf)) log("Done!",color='yellow') + + +# 3.2 album support +def parse_old_albums(): + setting_name = "db_upgrade_albums" + if get_maloja_info([setting_name]).get(setting_name): + pass + else: + pass + #set_maloja_info({setting_name:True})