fix: Add app_context() wrapper for thread-safe DB access
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
title: "애니 다운로더"
|
title: "애니 다운로더"
|
||||||
version: "0.4.5"
|
version: "0.4.6"
|
||||||
package_name: "anime_downloader"
|
package_name: "anime_downloader"
|
||||||
developer: "projectdx"
|
developer: "projectdx"
|
||||||
description: "anime downloader"
|
description: "anime downloader"
|
||||||
|
|||||||
@@ -1325,7 +1325,9 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
|
|||||||
# Call parent's download_completed first (handles file move)
|
# Call parent's download_completed first (handles file move)
|
||||||
super().download_completed()
|
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"])
|
db_entity = ModelAniLifeItem.get_by_anilife_id(self.info["_id"])
|
||||||
if db_entity is not None:
|
if db_entity is not None:
|
||||||
db_entity.status = "completed"
|
db_entity.status = "completed"
|
||||||
|
|||||||
@@ -136,6 +136,8 @@ class AnimeQueueEntity(FfmpegQueueEntity):
|
|||||||
def _update_db_status(self):
|
def _update_db_status(self):
|
||||||
"""Update DB status to completed - generic method for all sites."""
|
"""Update DB status to completed - generic method for all sites."""
|
||||||
try:
|
try:
|
||||||
|
from framework import app
|
||||||
|
with app.app_context():
|
||||||
# Get the web_list_model from module_logic
|
# Get the web_list_model from module_logic
|
||||||
model_class = getattr(self.module_logic, 'web_list_model', None)
|
model_class = getattr(self.module_logic, 'web_list_model', None)
|
||||||
if model_class is None:
|
if model_class is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user