From 9bb717135465e57ebe21b623dee78ab8620707ed Mon Sep 17 00:00:00 2001 From: Lost-MSth Date: Tue, 2 Jul 2024 22:18:00 +0800 Subject: [PATCH] [Bug fix] Update error & About bundle download - Data for Arcaea 5.8.0 - Fix a bug that the server's database updates from an old version may meet a challenge if `recent30` table has some strange data. - Fix the issue where the bundle downloading memory cache does not clean up. - Add a config term to only change the X-Accel-Redirect prefix for bundle downloading. --- latest version/core/bundle.py | 6 ++++ latest version/core/config_manager.py | 3 +- latest version/core/constant.py | 4 +-- latest version/core/sql.py | 5 ++-- latest version/database/init/packs.json | 18 ++++++++++++ latest version/database/init/singles.json | 36 +++++++++++++++++++++++ latest version/main.py | 2 +- 7 files changed, 68 insertions(+), 6 deletions(-) diff --git a/latest version/core/bundle.py b/latest version/core/bundle.py index 985d93c..265c110 100644 --- a/latest version/core/bundle.py +++ b/latest version/core/bundle.py @@ -226,6 +226,8 @@ class BundleDownload: if not sql_list: return [] + self.clear_expired_token() + self.c_m.executemany( '''insert into bundle_download_token values (?, ?, ?, ?)''', sql_list) @@ -246,3 +248,7 @@ class BundleDownload: f'Too many content bundle downloads, IP: {ip}, DeviceID: {device_id}', status=429) return file_path + + def clear_expired_token(self) -> None: + self.c_m.execute( + '''delete from bundle_download_token where time < ?''', (int(time() - Constant.BUNDLE_DOWNLOAD_TIME_GAP_LIMIT),)) diff --git a/latest version/core/config_manager.py b/latest version/core/config_manager.py index 9816022..c59c32e 100644 --- a/latest version/core/config_manager.py +++ b/latest version/core/config_manager.py @@ -16,7 +16,7 @@ class Config: OLD_GAME_API_PREFIX = [] # str | list[str] ALLOW_APPVERSION = [] # list[str] - + BUNDLE_STRICT_MODE = True SET_LINKPLAY_SERVER_AS_SUB_PROCESS = True @@ -49,6 +49,7 @@ class Config: DOWNLOAD_USE_NGINX_X_ACCEL_REDIRECT = False NGINX_X_ACCEL_REDIRECT_PREFIX = '/nginx_download/' + BUNDLE_NGINX_X_ACCEL_REDIRECT_PREFIX = '/nginx_bundle_download/' DOWNLOAD_TIMES_LIMIT = 3000 DOWNLOAD_TIME_GAP_LIMIT = 1000 diff --git a/latest version/core/constant.py b/latest version/core/constant.py index f775f13..bab19dd 100644 --- a/latest version/core/constant.py +++ b/latest version/core/constant.py @@ -1,7 +1,7 @@ from .config_manager import Config -ARCAEA_SERVER_VERSION = 'v2.11.3.14' -ARCAEA_DATABASE_VERSION = 'v2.11.3.13' +ARCAEA_SERVER_VERSION = 'v2.11.3.15' +ARCAEA_DATABASE_VERSION = 'v2.11.3.15' ARCAEA_LOG_DATBASE_VERSION = 'v1.1' diff --git a/latest version/core/sql.py b/latest version/core/sql.py index 96035bf..6a679e6 100644 --- a/latest version/core/sql.py +++ b/latest version/core/sql.py @@ -450,10 +450,11 @@ class DatabaseMigrator: for j in range(30): rating = i[1 + j * 2] rating = float(rating) if rating else 0 - song_id_difficulty = i[2 + j * 2] + song_id_difficulty: str = i[2 + j * 2] if song_id_difficulty: song_id = song_id_difficulty[:-1] - difficulty = int(song_id_difficulty[-1]) + difficulty = song_id_difficulty[-1] + difficulty = int(difficulty) if difficulty.isdigit() else 0 else: song_id = '' difficulty = 0 diff --git a/latest version/database/init/packs.json b/latest version/database/init/packs.json index 650680a..5357e1c 100644 --- a/latest version/database/init/packs.json +++ b/latest version/database/init/packs.json @@ -808,5 +808,23 @@ ], "price": 700, "orig_price": 700 + }, + { + "name": "groovecoaster_append_1", + "items": [ + { + "type": "pack", + "id": "groovecoaster_append_1", + "is_available": true + }, + { + "type": "core", + "amount": 3, + "id": "core_generic", + "is_available": true + } + ], + "price": 300, + "orig_price": 300 } ] \ No newline at end of file diff --git a/latest version/database/init/singles.json b/latest version/database/init/singles.json index e963d38..007cbed 100644 --- a/latest version/database/init/singles.json +++ b/latest version/database/init/singles.json @@ -1828,5 +1828,41 @@ ], "orig_price": 100, "price": 100 + }, + { + "name": "hypervision", + "items": [ + { + "type": "single", + "id": "hypervision", + "is_available": true + }, + { + "type": "core", + "amount": 1, + "id": "core_generic", + "is_available": true + } + ], + "orig_price": 100, + "price": 100 + }, + { + "name": "stargateextreme", + "items": [ + { + "type": "single", + "id": "stargateextreme", + "is_available": true + }, + { + "type": "core", + "amount": 1, + "id": "core_generic", + "is_available": true + } + ], + "orig_price": 100, + "price": 100 } ] \ No newline at end of file diff --git a/latest version/main.py b/latest version/main.py index 8f84d60..ac78ec5 100644 --- a/latest version/main.py +++ b/latest version/main.py @@ -111,7 +111,7 @@ def bundle_download(token: str): # nginx X-Accel-Redirect response = make_response() response.headers['Content-Type'] = 'application/octet-stream' - response.headers['X-Accel-Redirect'] = Config.NGINX_X_ACCEL_REDIRECT_PREFIX + file_path + response.headers['X-Accel-Redirect'] = Config.BUNDLE_NGINX_X_ACCEL_REDIRECT_PREFIX + file_path return response return send_from_directory(Constant.CONTENT_BUNDLE_FOLDER_PATH, file_path, as_attachment=True, conditional=True) except ArcError as e: