From ba74c2b0a569c574d83740a8f4ff0c94b92cee88 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Fri, 30 Oct 2026 21:40:20 -0700 Subject: [PATCH] refactor(quality): end the job runners with an explicit return --- py/api/backup_restore.py | 1 + py/api/duplicate_files.py | 3 ++- py/api/image_delete.py | 3 ++- py/api/library_location.py | 1 + py/api/log_cleanup.py | 1 + py/api/lora_import_routes.py | 8 +++++--- py/api/maintenance.py | 1 + py/api/workflow_storage.py | 1 + 8 files changed, 14 insertions(+), 5 deletions(-) diff --git a/py/api/backup_restore.py b/py/api/backup_restore.py index a83ecbfa..ab3d030a 100644 --- a/py/api/backup_restore.py +++ b/py/api/backup_restore.py @@ -971,6 +971,7 @@ class BackupRestoreRoutesMixin: line = restored_line(staged.summary) job.log_line(line) job.update(progress=100, status_line=line) + return None async def _outlive_cancel(future): diff --git a/py/api/duplicate_files.py b/py/api/duplicate_files.py index 34e15ed4..9a844253 100644 --- a/py/api/duplicate_files.py +++ b/py/api/duplicate_files.py @@ -574,12 +574,13 @@ class DuplicateFilesMixin: return _fail_job(job, "sources-changed", SOURCES_CHANGED) ok, backup = await self._safety_backup_step(job, db, backup_on) if not ok: - return + return None try: await self._remove_duplicates(job, db, plan, backup) finally: if backup: await self._prune_backup_pool(job, db) + return None async def _remove_duplicates(self, job, db, plan, backup): targets = plan.payload["targets"] diff --git a/py/api/image_delete.py b/py/api/image_delete.py index 862cda26..b81b8497 100644 --- a/py/api/image_delete.py +++ b/py/api/image_delete.py @@ -330,12 +330,13 @@ class ImageDeleteMixin: return _fail_job(job, "sources-changed", SOURCES_CHANGED) ok, backup = await self._safety_backup_step(job, db, backup_on) if not ok: - return + return None try: await self._delete_images(job, db, targets, mode, backup) finally: if backup: await self._prune_backup_pool(job, db) + return None async def _delete_images(self, job, db, targets, mode, backup): job.update(total=len(targets), status_line=TITLES[mode]) diff --git a/py/api/library_location.py b/py/api/library_location.py index 8c4ec324..d601f00d 100644 --- a/py/api/library_location.py +++ b/py/api/library_location.py @@ -373,6 +373,7 @@ class LibraryLocationRoutesMixin: line += ". Logs move at the next restart." job.log_line(line) job.update(progress=100, status_line=line) + return None @staticmethod def _fail_library_move(job, code, message): diff --git a/py/api/log_cleanup.py b/py/api/log_cleanup.py index f6248388..c1c2cd41 100644 --- a/py/api/log_cleanup.py +++ b/py/api/log_cleanup.py @@ -205,3 +205,4 @@ class LogCleanupMixin: line += f", {failed} could not be deleted" job.log_line(line) job.update(processed=len(files), progress=100, status_line=line) + return None diff --git a/py/api/lora_import_routes.py b/py/api/lora_import_routes.py index a09ec689..f6eec8c6 100644 --- a/py/api/lora_import_routes.py +++ b/py/api/lora_import_routes.py @@ -436,7 +436,7 @@ class LoraImportRoutesMixin: job.log_line(f"{CANCELLED} {CACHE_NOTE}") job.update(status_line=CANCELLED) job.finish("cancelled") - return + return None except Exception: self.logger.exception("LoRA import staging failed") return _fail_job(job, "import-failed", f"{FAILED} {CACHE_NOTE}") @@ -455,10 +455,10 @@ class LoraImportRoutesMixin: job.log_line(f"{CANCELLED} {CACHE_NOTE}") job.update(status_line=CANCELLED) job.finish("cancelled") - return + return None ok, _backup = await self._safety_backup_step(job, db, backup_on) if not ok: - return + return None # I1: the files are listed and fingerprinted again right before the # replace, so a file changed, removed or added while the downloads ran # (LoraManager refreshing its CivitAI info) aborts with nothing deleted. @@ -466,6 +466,7 @@ class LoraImportRoutesMixin: return _fail_job(job, "plan-changed", f"{SOURCE_CHANGED} {CACHE_NOTE}") job.update(status_line="Replacing the LoRA collection", progress=95) await self._replace_in_job(job, db, plan, staged) + return None def _count_downloads(self, job, staged): downloaded = staged.stats.get("downloaded", 0) @@ -518,3 +519,4 @@ class LoraImportRoutesMixin: staged.stats.get("download_errors", 0), ) job.update(progress=100, processed=job.total, status_line=line) + return None diff --git a/py/api/maintenance.py b/py/api/maintenance.py index e7d34020..d93a8973 100644 --- a/py/api/maintenance.py +++ b/py/api/maintenance.py @@ -673,6 +673,7 @@ class MaintenanceRoutesMixin: line = _changed_line(plan.operation, result["changed"], result.get("marks", 0)) job.log_line(line) job.update(progress=100, status_line=f"{line} ยท {backup_note(backup)}") + return None def _maintenance_rows(self, operation, described): """Outcome rows for the changed records (root-relative paths only).""" diff --git a/py/api/workflow_storage.py b/py/api/workflow_storage.py index 753c197b..fde4be76 100644 --- a/py/api/workflow_storage.py +++ b/py/api/workflow_storage.py @@ -275,3 +275,4 @@ class WorkflowStorageRoutesMixin: job.record_counted("changed", 1) job.log_line(line) job.update(progress=100, status_line=line) + return None