fix: Add app_context() wrapper for thread-safe DB access

This commit is contained in:
2026-01-02 16:45:11 +09:00
parent 87259d4c7c
commit f6f69f2136
3 changed files with 42 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
title: "애니 다운로더"
version: "0.4.5"
version: "0.4.6"
package_name: "anime_downloader"
developer: "projectdx"
description: "anime downloader"

View File

@@ -1325,7 +1325,9 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
# Call parent's download_completed first (handles file move)
super().download_completed()
# Update DB status
# Update DB status - wrap in app context since this runs in a thread
from framework import app
with app.app_context():
db_entity = ModelAniLifeItem.get_by_anilife_id(self.info["_id"])
if db_entity is not None:
db_entity.status = "completed"

View File

@@ -136,6 +136,8 @@ class AnimeQueueEntity(FfmpegQueueEntity):
def _update_db_status(self):
"""Update DB status to completed - generic method for all sites."""
try:
from framework import app
with app.app_context():
# Get the web_list_model from module_logic
model_class = getattr(self.module_logic, 'web_list_model', None)
if model_class is None: