feat(library): content fingerprint + path-resilient sync + stream self-heal
Stop treating the absolute path as a file's identity so a base-path change (host binary→docker remap, moved media folder, remount) no longer makes the server duplicate and orphan library rows. - fingerprint.go: ComputeFingerprint = sha256(size ‖ first 1MiB ‖ last 1MiB), a stable content identity that survives rename/move/base-path change. Cached in LibraryItem and reused on incremental scans when size+mtime are unchanged. - sync: send fingerprint + rel_path (relative to the scan root) + agent_id in the library-sync request, so the server can move a row in place and scope stale-cleanup per agent. - daemon: force a FULL re-scan (with a user-facing WARNING) when the scan root changed since the last cache, so the server re-maps by fingerprint instead of duplicating. basePathChanged compares filepath.Clean'd roots. - daemon: relocateUnreachable self-heals a stream request whose path is under an old root but whose file still exists under a current allowed root, so playback works immediately without waiting for the re-scan. Conservative: requires a 3-segment tail and re-checks containment after resolving symlinks so it can neither serve the wrong file nor escape the allowed dirs. See docs/plans/unarr-path-resilience.md in the web repo.
This commit is contained in:
parent
e298ff6c05
commit
b6ddeea129
9 changed files with 396 additions and 38 deletions
|
|
@ -318,6 +318,7 @@ type DebridAccount struct {
|
|||
type LibrarySyncRequest struct {
|
||||
Items []LibrarySyncItem `json:"items"`
|
||||
ScanPath string `json:"scanPath"`
|
||||
AgentID string `json:"agentId,omitempty"` // lets the server scope stale-cleanup per agent
|
||||
IsLastBatch bool `json:"isLastBatch"`
|
||||
SyncStartedAt string `json:"syncStartedAt,omitempty"` // ISO-8601; same for all batches in a session
|
||||
}
|
||||
|
|
@ -346,8 +347,14 @@ type LibrarySyncItem struct {
|
|||
// Integrity flags a damaged / incompletely-downloaded file ("damaged" or
|
||||
// empty). IntegrityReason is a stable code (ebml_corrupt, moov_missing,
|
||||
// no_duration, …) the web maps to a localized "re-download" message.
|
||||
Integrity string `json:"integrity,omitempty"`
|
||||
IntegrityReason string `json:"integrityReason,omitempty"`
|
||||
Integrity string `json:"integrity,omitempty"`
|
||||
IntegrityReason string `json:"integrityReason,omitempty"`
|
||||
// Path resilience: a stable content identity + the file's location relative
|
||||
// to its library root, so the server can move a row in place on a rename /
|
||||
// base-path change instead of duplicating it.
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
RelPath string `json:"relPath,omitempty"`
|
||||
LibraryRootKey string `json:"libraryRootKey,omitempty"`
|
||||
}
|
||||
|
||||
// LibrarySyncResponse is returned after syncing library items.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue