mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-08 06:50:15 -03:00
fix(downloads): reject re-insertion of download_ids already in history
In add_to_queue, check download_history before INSERT OR IGNORE. Without this check, a fire-and-forget /queue/complete failure on the extension side would allow the same download_id to be re-inserted after complete_download() deleted it from the queue — creating phantom queued entries for already- finished downloads.
This commit is contained in:
@@ -154,13 +154,23 @@ class DownloadQueueService:
|
|||||||
"""Insert a new download into the queue.
|
"""Insert a new download into the queue.
|
||||||
|
|
||||||
Returns the inserted row as a dict (or an empty dict if the
|
Returns the inserted row as a dict (or an empty dict if the
|
||||||
download_id already exists).
|
download_id already exists in the queue or has a terminal
|
||||||
|
record in history).
|
||||||
"""
|
"""
|
||||||
now = time.time()
|
now = time.time()
|
||||||
file_params_json = json.dumps(file_params) if file_params is not None else None
|
file_params_json = json.dumps(file_params) if file_params is not None else None
|
||||||
|
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
conn = self._get_conn()
|
conn = self._get_conn()
|
||||||
|
|
||||||
|
# Reject download_ids that already have a terminal record in history.
|
||||||
|
history_row = conn.execute(
|
||||||
|
"SELECT 1 FROM download_history WHERE download_id = ? LIMIT 1",
|
||||||
|
(download_id,),
|
||||||
|
).fetchone()
|
||||||
|
if history_row is not None:
|
||||||
|
return {}
|
||||||
|
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"""
|
"""
|
||||||
INSERT OR IGNORE INTO download_queue (
|
INSERT OR IGNORE INTO download_queue (
|
||||||
|
|||||||
Reference in New Issue
Block a user