From cff827383e59848c25e26042f37a3731960a0e41 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 16 Aug 2025 10:14:49 -0600 Subject: [PATCH] Marking download as complete when an archive is uploaded by singlefile browser extension. --- modules/archive/api.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/archive/api.py b/modules/archive/api.py index 5268338f..a649bd6e 100644 --- a/modules/archive/api.py +++ b/modules/archive/api.py @@ -1,11 +1,11 @@ import multiprocessing import queue from http import HTTPStatus -from multiprocessing.sharedctypes import SynchronizedArray from sanic import response, Request, Blueprint from sanic_ext import validate from sanic_ext.extensions.openapi import openapi +from sqlalchemy.orm import Session from wrolpi.api_utils import json_response, api_app from wrolpi.common import logger, wrol_mode_check, api_param_limiter, TRACE_LEVEL @@ -89,7 +89,7 @@ async def get_upload_singlefile(request: Request): @register_switch_handler('singlefile_upload_switch_handler') async def singlefile_upload_switch_handler(url=None): """Used by `post_upload_singlefile` to upload a single file""" - from wrolpi.downloader import download_manager, Download + from wrolpi.downloader import Download from . import ArchiveDownloader q: multiprocessing.Queue = api_app.shared_ctx.archive_singlefiles @@ -121,9 +121,9 @@ async def singlefile_upload_switch_handler(url=None): if url and (download := Download.get_by_url(url)): if (download.is_failed or download.is_deferred) and download.downloader == ArchiveDownloader.name: # Download was attempted and failed, user manually archived the URL. - if trace_enabled: - logger.trace(f'singlefile_upload_switch_handler deleting incomplete download for {url}') - download_manager.delete_download(download.id) + download.complete() + download.location = archive.location + Session.object_session(download).commit() # Call this function again so any new singlefiles can be archived. singlefile_upload_switch_handler.activate_switch()