Flush incremental caption updates on stop and failure

This commit is contained in:
Sleeps
2026-10-07 14:26:28 +01:00
parent 6a24c53092
commit 5895342f95
+7 -2
View File
@@ -195,6 +195,7 @@ class CaptionJobManager:
return self.status()
def _prepare_and_run(self, library_ids: list[str], force: bool) -> None:
caption_sync: CaptionMeiliSync | None = None
try:
init_db(settings.db_path)
args = SimpleNamespace(
@@ -265,7 +266,8 @@ class CaptionJobManager:
self._run(args, rows, caption_sync)
except CaptionJobStopped:
self._set_gpu_busy(False)
caption_sync.flush()
if caption_sync is not None:
caption_sync.flush()
self._pause_requested.clear()
self._stop_requested.clear()
self._resume_event.set()
@@ -283,7 +285,8 @@ class CaptionJobManager:
)
except Exception as exc:
self._set_gpu_busy(False)
caption_sync.flush()
if caption_sync is not None:
caption_sync.flush()
self._progress(
{
"running": False,
@@ -473,6 +476,7 @@ class CaptionJobManager:
)
except CaptionJobStopped:
self._set_gpu_busy(False)
caption_sync.flush()
self._pause_requested.clear()
self._stop_requested.clear()
self._resume_event.set()
@@ -489,6 +493,7 @@ class CaptionJobManager:
)
except Exception as exc:
self._set_gpu_busy(False)
caption_sync.flush()
self._progress(
{
"running": False,