feat(libraries): scope a library scan to one registered folder
POST /api/libraries/:id/scan accepts an optional {"folder_path": "..."}:
the scan then covers exactly that one registered folder's subtree instead
of the whole library. The path is validated against the library's
registered folders — anything else is a 400, never trusted. An omitted
body keeps today's full-library behavior, and coalescing (409 with the
active job) is unchanged.
The LibraryPanel folder rows get a per-folder Scan button: pure htmx
attributes posting to the same scan endpoint, with hxValsFolderScan
emitting plain eval-free JSON for hx-vals alongside the existing
hxValsFolderDelete precedent. Progress surfaces through the existing
active-scan polling; no new client code.
Safety: the scanner's archive-reconciliation guard (previous commit)
skips partially-covered libraries, so a one-folder scan cannot mark the
library's other folders' items missing.
This commit is contained in:
1 parent
6f37be59fc
commit
0f1d0abbb0
6 files changed
+286
-197
No files matched your search
@@ -8,10 +8,17 @@ area: libraries
|
||||
|
||||
# Scan Library
|
||||
|
||||
Enqueues a full scan of one library's configured folders. The library id comes
|
||||
Enqueues a scan of one library's configured folders. The library id comes
|
||||
from the path — no request body is needed (the generic `POST /api/scanner/scan`
|
||||
variant is the one that takes `folder_paths`).
|
||||
|
||||
**Per-folder scope**: an optional body of `{"folder_path": "…"}` restricts the
|
||||
scan to ONE of the library's registered folders (the per-folder Scan buttons
|
||||
in the library panel). The path must be a registered folder — anything else is
|
||||
a **400**. A scoped scan never runs archive reconciliation for the library's
|
||||
other folders, so items outside the scanned folder cannot be marked missing
|
||||
by it.
|
||||
|
||||
Scans are **coalesced**: if a scan for this library is already pending or
|
||||
running you get **409** with the active job id instead of a second scan.
|
||||
|
||||
@@ -29,7 +36,7 @@ running you get **409** with the active job id instead of a second scan.
|
||||
|
||||
| Status | Body | When |
|
||||
| ------ | ---- | ---- |
|
||||
| 400 | `{"error": "invalid library id"}` / `{"error": "library has no folders configured"}` | malformed id / empty library |
|
||||
| 400 | `{"error": "invalid library id"}` / `{"error": "library has no folders configured"}` / `{"error": "folder_path is not one of this library's registered folders"}` | malformed id / empty library / unregistered folder scope |
|
||||
| 404 | `{"error": "library not found or has no folders"}` | unknown library |
|
||||
| 409 | `{"error": "a scan for this library is already pending or running", "active_job_id": "..."}` | scan coalescing |
|
||||
| 500 | `{"error": "failed to enqueue scan job: ..."}` | queue failure |
|
||||
Reference in new issue
Block a user