This commit is contained in:
Dispatcharr 2025-10-10 18:10:56 -05:00
parent f595ffa94a
commit 47eb514cd9
2 changed files with 11 additions and 10 deletions

View file

@ -440,6 +440,17 @@ def _maybe_mark_scan_completed(scan: LibraryScan) -> None:
if discovery_done and metadata_done and artwork_done:
summary = scan.summary or ""
scan.mark_completed(summary=summary)
if scan.library_id:
now = timezone.now()
Library.objects.filter(pk=scan.library_id).update(
last_scan_at=now,
last_successful_scan_at=now,
updated_at=now,
)
if getattr(scan, "library", None):
scan.library.last_scan_at = now
scan.library.last_successful_scan_at = now
scan.library.updated_at = now
_emit_scan_update(scan, status="completed")

View file

@ -200,26 +200,16 @@ class LibraryScanner:
if summary:
self.scan.summary = summary
self.scan.log = "\n".join(self.log_messages)
self.scan.finished_at = timezone.now()
self.scan.status = LibraryScan.STATUS_COMPLETED
self.scan.processed_files = self.scan.total_files
self.scan.save(
update_fields=[
"matched_items",
"unmatched_files",
"summary",
"log",
"finished_at",
"status",
"processed_files",
"updated_at",
]
)
self.library.last_scan_at = timezone.now()
self.library.last_successful_scan_at = timezone.now()
self.library.save(update_fields=["last_scan_at", "last_successful_scan_at", "updated_at"])
def _ensure_file_record(
self, location: LibraryLocation, file_path: Path
) -> Optional[tuple[MediaFile, bool]]: