Fix: Async Scan race condition
This commit is contained in:
parent
cc9c0500e2
commit
6082cf5bfd
1 changed files with 3 additions and 1 deletions
|
|
@ -921,7 +921,7 @@ def api_recovery_scan():
|
|||
|
||||
def run_scan_async():
|
||||
global SCAN_CACHE
|
||||
SCAN_CACHE["status"] = "scanning"
|
||||
# SCAN_CACHE["status"] = "scanning" # Already set in main thread
|
||||
SCAN_CACHE["results"] = None
|
||||
try:
|
||||
results = scan_for_unindexed_videos()
|
||||
|
|
@ -933,6 +933,8 @@ def api_recovery_scan():
|
|||
SCAN_CACHE["results"] = str(e)
|
||||
log(f"❌ Async scan failed: {e}")
|
||||
|
||||
# Set status IMMEDIATELY to avoid race condition where poll sees "idle"
|
||||
SCAN_CACHE["status"] = "scanning"
|
||||
SCAN_THREAD = threading.Thread(target=run_scan_async)
|
||||
SCAN_THREAD.start()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue