Skip to content

fix(scanner): keep a renamed file's row when the rename changes its parsed title - #4039

Merged
Quick104 merged 5 commits into
mainfrom
fix/scanner-reuse-artifacts-on-rename
Nov 13, 2026
Merged

Quick104 merged 5 commits into
mainfrom
fix/scanner-reuse-artifacts-on-rename

Conversation

@Quick104

@Quick104 Quick104 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none changed; the change reaches #1231 C1 (webhook-reported paths go through the same per-file scan step) and #1155 C1 (the marker image reset trigger), and neither case's behavior changes

Renaming a file so that its path parses differently gives it a new media_files row, even though its bytes are unchanged. The common trigger is letting Radarr or Sonarr add {tmdb-…}, {imdb-…}, or {tvdb-…} tags to an existing library. Every renamed file then loses its trickplay, chapter images, probe data, subtitles and timing corrections, and offline downloads, and Silo regenerates trickplay and chapter images for the whole library. One user reported this after retagging a large library.

#2877 made a renamed file keep its row, but only when the new path parses to the same title. With this change the bytes alone decide whether the row is kept, and the path only decides whether the row keeps its match.

Approach

A file that appears at a path with no row takes over the one row in the same library with the same size, OSHash, and modification time whose old path is gone under a root that answers and is not empty. If several rows qualify, the one whose old path names the same title wins, but only if exactly one does; otherwise the file is ingested as new, as before.

What the new path says then decides the row's links:

  • Same parsed title: links stay, as in fix(scanner): keep a file's row when it is renamed or moved #2877.
  • A path that matching would resolve to the linked title: links stay. The check follows matching's own order without calling a provider: a claim on the new content group or root, for a series a title already linked under the same show folder, then the provider IDs the scanner derives for the group, compared with the catalog item in the type's anchor precedence (TMDB first for a movie, TVDB first for a series). An operator override, a different episode, or anything that cannot be known locally means a rematch. This is the Radarr/Sonarr retag case, and it covers tags from any provider. The comparison moved from internal/metadata to internal/catalog unchanged so the scanner and matching share it.
  • Anything else: the row moves, drops its content and episode links, takes season and episode numbers, edition, and added date from the new path and the current scan, and is matched like a new file. A rename made to fix a wrong match therefore still matches afresh. Detected markers and marker images are cleared by the existing trigger; everything derived from the bytes stays.

When a row leaves its title, a missing stand-in row is written at the old path in the same statement, carrying the old links, held first-seen dates, and missing_since. The old title then goes through the normal removal grace: without the stand-in, reconciliation would delete the item at once, with its collections, manual edits, and added date, even when the rematch finds the same title again. The stand-in names the row it stands for in a new nullable column, media_files.stand_in_for_file_id. If the same bytes come back to the old path, that row takes the path, links, numbers, edition, and dates back and the stand-in is removed, so undoing a rename restores the file as it was. When the scan cannot tell whether the returning file is that row's (a database error, or the path it left is under a root that is unreachable or empty), it fails the file for that scan and a later scan decides. A different file arriving at a stand-in's path is written onto it and clears the marker.

Offline downloads stay with the title they were authorized for. In the same statement that retitles a row, its downloads for the old title move to the stand-in, so they are refused as a missing file's are and deleted with it after the grace, as they were before this change. Undoing the rename moves them back. A prepared remux or transcode is served, and prepared again, only for a download on the file row it was made from, so a moved download never gets the retitled row's copy.

Marker images used to reset on any path change, including a relink that kept the links. The trigger no longer compares file_path; changed bytes are still caught by hash, size, modification time, and duration. Image identities hash the path, so the relink rewrites them for the new path in the same update.

Two migrations: one replaces the marker image trigger function, the other adds the nullable column. No API or settings change, and clients and jellycompat see only a file id that stays the same across more renames. The rule is recorded in docs/architecture/missing-files.md. Extras and Books libraries are unchanged. The user manual's "Renaming and moving files" section does not describe artifact regeneration, so it needs no update.

Validation

  • The database-backed scanner test runs real files against a freshly migrated Postgres through full, subtree, and file-level scans: 33 cases pass. It covers provider tags on folders, files, and both, from each provider, for movies and series; a folder tag that outranks a conflicting file tag; a tag that contradicts the linked title on its anchor provider; a rename into a root claimed for the title; a filename tag naming another show inside the same series folder; retitles; a reverted retitle; a revert that cannot be decided until its root is healthy again; a stand-in removed by the trash sweep before the file returns; a stand-in whose original row was deleted; two vanished identical copies; and the cases that must still get a new row. Each kept row is checked for its trickplay row, chapter image, subtitle timing, markers, and offline download, and retitled rows are checked for cleared links and a metadata queue entry.
  • The new cases fail without the change, and the fixes for non-anchor provider tags, the group key version fallback, the reverted rename, and the imported edition were each confirmed by reverting them and watching their cases fail.
  • go build ./..., gofmt, go mod tidy -diff, go vet ./..., make lint-changed, make lint-router-recovery, make verify-migrations, make verify-local-paths, make verify-case-collisions, make verify-size-ratchet, make verify-bidi, make verify-apiv2-openapi: pass. Both migrations were applied, rolled back, and re-applied.
  • Focused Go tests for the scanner, chapter thumbnails, naming, models, catalog, and migrations pass on macOS, except two scanner tests that depend on filesystem behavior and fail the same way on main there.
  • A database-backed downloads test checks that a download moved to a stand-in is neither served nor prepared again from the retitled row's prepared copy.
  • Not run locally: make test-go as a whole and make verify-route-inventory, which does not type-check on macOS because of a Linux-only cgo file; CI covers both. Web checks were not run; nothing under web/ changed.
  • Not exercised on a live deployment, and the real matcher does not run in the scanner test, so "the retitled row is matched again" is checked as "unlinked and queued", not end to end.
  • The retry when a match links the row while it is reclaiming its stand-in has no test; that timing could not be driven deterministically.

Evidence

No user-visible change. The page holds the steps, the build, and the test results.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-4039/

Risks

  • OSHash samples the first and last 64 KiB, so with size and modification time it is a strong heuristic, not proof. Because the title no longer has to match, two different files that agree on all three, where one vanished as the other appeared, would now share a row even under different titles.
  • The stand-in is a synthetic missing row. It shows in missing-file lists and counts like the old row did before this change. How admin views display it was not checked.
  • Undoing a title-changing rename restores trickplay, chapter images, subtitles, downloads, links, and dates, but detected markers and marker images are cleared when the links change and are detected again.
  • A match job that read a row before it was retitled can still write its result afterwards, because the matcher's link writes are fenced on the row id only. The row is then linked back to the old title and is not rematched. Matched files are not in the queue, so a bulk rename of a matched library is unlikely to hit it; a file being matched or retried as it is renamed can. fix(metadata): refuse a match's link write once the file has moved #4041, stacked on this PR, closes it with a path fence on the matcher's link writes.
  • A download registered at the moment its file is being retitled can miss the move to the stand-in and stay on the live row under the old title, because registration resolves the file without a lock and inserts later. The window is the time between those two steps. fix(downloads): write a download only while its file names the download's title #4042, stacked on this PR, closes it with a row lock and title check in the download-writing statements.
  • A plain matcher relink of a file between items (no rename) still leaves its downloads on the old title, as on main.
  • A file-level scan of only the new path does not reconcile the old title's membership; that waits for the old path's scan or a full scan, as before.
  • The keep-links check mirrors matching's lookup order but is not compared against a real matcher run. Where the two disagree, a file keeps a link that a rematch would have changed, or is rematched needlessly.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code agent tools and subagents
  • Model(s): claude-opus-5-5 (wrote the code; separate instance for adversarial review), claude-fable-5-2 (diagnosis, direction, cleanup pass, verification, this description)
  • Involvement: Fully AI-generated (maintainer review pending)
  • Adversarial review: a separate claude-opus-5-5 instance reviewed the diff twice. The first round led to the reclaim of a reverted rename, the tag comparison against stored provider IDs, the group key version fallback, the added-date reset, and new-path variant hints. The second led to the plain column in place of a foreign key and index, the retry and fall-through on the reclaim's races, and restoring an imported edition. Bot review then led to failing an undecided reclaim instead of ingesting the file, deciding links the way matching would, fewer filesystem probes per lookup, moving downloads with the title they were authorized for, leaving the renamed row out of the series sibling lookup, and tying prepared copies to their own file row.

🤖 Generated with Claude Code

…arsed title

A file whose bytes are unchanged (same size, OSHash, and modification time)
now keeps its media_files row across any rename or move, so trickplay,
chapter images, probe data, subtitles, and downloads follow it. Before, a
rename that changed what the path parses to, such as adding a provider ID
tag, got a new row and regenerated everything.

When the new path's provider tags agree with the linked title's stored IDs,
the links stay. Otherwise the row drops its links and is matched like a new
file, and a missing stand-in row at the old path holds the old title through
the usual removal grace. Undoing such a rename gives the row its path and
links back.

Marker thumbnails no longer reset on a path change alone; the relink rewrites
their path-hashed identities.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Nov 12, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T20:19:05.668338Z d38988d New commits
🔒 Security Review ✅ Completed 2026-11-12T20:26:34.896589Z d38988d New commits

Security findings

Advisory findings (2)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The scanner now selects moved-file rows using file attributes and title identity. It can retain links, retitle rows, create stand-ins for old paths, and reclaim stand-ins when files return. Marker thumbnails can persist across path changes when their other identity checks pass.

Changes: Moved-file handling

Layer / File(s) Summary
Identity and thumbnail rules
migrations/sql/20261112172920_mark_retitle_stand_in_rows.sql, migrations/sql/20261112170646_keep_marker_thumbnails_across_renames.sql, internal/chapterthumbs/marker_snapshots.go, internal/scanner/file_repo_marker_thumbnails.go, internal/catalog/provider_identity.go, internal/metadata/service.go
The schema adds stand-in tracking. Marker snapshots no longer reject path changes alone, and the migration excludes file_path from thumbnail invalidation in its Up definition. Provider-ID contradiction checks use a shared catalog function.
Candidate selection and title matching
internal/scanner/file_relink.go, internal/scanner/file_repo.go, internal/catalog/provider_identity.go, internal/metadata/service.go, docs/architecture/missing-files.md
The scanner selects candidates using file attributes and vanished-path status, then uses title identity and matching evidence to decide whether to retain links or retitle. Repository lookup supports claims and excludes the candidate file when checking observed roots.
Fenced relink, retitle, and reclaim
internal/scanner/file_repo_relink.go, internal/scanner/file_repo.go, internal/scanner/scanner.go, internal/scanner/file_repo_marker_thumbnails.go
Repository updates fence changes against the verified row state. Retitles can create stand-ins, and returning files can reclaim them. The scanner checks for reclamation before normal processing.
Parked download file checks
internal/downloads/service.go, internal/downloads/storage_reprepare.go, internal/downloads/parked_download_db_test.go, scripts/ci/db-contracts.txt
Download serving and re-preparation reject artifacts associated with a different media-file row. A database test covers parked downloads.
Relink coverage and documented behavior
internal/scanner/file_relink_db_test.go, docs/architecture/missing-files.md
Database tests cover candidate selection, link retention, retitling, stand-in reclamation, and scan scopes. The architecture documentation describes eligibility and row transitions.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Scanner
  participant FileRepository
  participant LibraryRoots
  participant Database
  Scanner->>FileRepository: Find moved-file candidates
  FileRepository->>Database: Query candidate rows and claims
  Scanner->>LibraryRoots: Probe candidate paths
  LibraryRoots-->>Scanner: Return path availability
  Scanner->>FileRepository: Relink, retitle, or reclaim selected row
  FileRepository->>Database: Apply fenced row and stand-in updates
Loading

Possibly related PRs

Suggested labels: impact: data-loss

Suggested reviewers: rhainland

Merge Risk: Moderate · up to d3898

After a renamed file is retitled, an in-flight metadata match job could still link it back to its old title. The author acknowledges this and defers the fix to a follow-up. The race is narrow, but it should be accepted explicitly before merge.

Security architecture risk: Low · up to d3898

The change preserves derived media data across renames and adds checks that prevent parked downloads from using another file’s prepared output. No new unauthorized access was demonstrated. Concurrent transfers during renames and downgrade behavior remain incompletely validated.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant input boundary is a filesystem path change observed in a configured media folder. A successful transition can reassign every qualifying download referencing the selected row, not just one user’s download. Candidate lookup does not search other media folders, and inspected serving paths retain user, profile/device, and content-access checks.

Trust Boundaries and Controls

  • observed — Prepared-output serving checks artifact-to-download file identity before constructing either a local or remote target. Original-file serving rejects a missing stand-in. Re-preparation re-reads and locks the stored download after locking its artifact, so a park committed before that locked read is not hidden by the caller’s stale copy.

Resilience and Maintainability Implications

  • observed — Serving uses a previously loaded download snapshot without holding its row lock through streaming. The inspected tests assert parked-download rejection, stale-copy preparation rejection, return-path reassignment, sweep cleanup, and uncertain-root deferral; they do not establish revocation semantics for a park overlapping an already authorized transfer. This remains an evidence gap, not a demonstrated new access bypass.

Hardening Proposals

  • proposed — Define the authorization point for transfers overlapping retitle or reclaim, then validate deterministic park-versus-serve and park-versus-reprepare schedules, transaction interruption, and downgrade with populated stand-ins. Verify that failed transitions leave download ownership unchanged and cannot authorize preparation or new transfers from the wrong file.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(scanner): keep a renamed file's row when the rename changes its parsed title" matches the main change in the changeset. The raw summary shows moved-file relinking in internal/scanner/fi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description is specific and related to the changeset. It explains the problem (renamed files losing their row and derived artifacts when the parsed title changes), the approach (byte-…
Full details: Title check

Explanation

The title "fix(scanner): keep a renamed file's row when the rename changes its parsed title" matches the main change in the changeset. The raw summary shows moved-file relinking in internal/scanner/file_relink.go, retitling with a stand-in row, and a new stand_in_for_file_id column. The title names the primary behavior, which is keeping the row when the parsed title changes. It is 80 characters, which is a little long but still clear.

Full details: Description check

Explanation

The pull request description is specific and related to the changeset. It explains the problem (renamed files losing their row and derived artifacts when the parsed title changes), the approach (byte-based identity matching, link-keeping rules, stand-in rows for the old title, marker trigger change, and downloads moved with the title), the two migrations, and the validation performed. It also lists risks and the evidence location. This matches the files in the raw summary, including the scanner relink logic, the stand-in column migration, the marker trigger migration, and the downloads changes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bcb78ac2-eeae-4004-b7bc-d3da926849e0
Commits

Reviewing files that changed from the base of the PR and between 41771e8 and d38988d.

Files selected for processing: 2

  • internal/downloads/parked_download_db_test.go
  • internal/downloads/storage_reprepare.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: perf Unusable slowness on normal hardware priority: P1 Core-path bug; painful workaround — next after P0 labels Nov 12, 2026
Comment thread internal/scanner/file_relink.go Resolved
Comment thread internal/scanner/file_relink.go Resolved
Comment thread internal/scanner/file_relink.go Resolved
Comment thread internal/scanner/file_relink.go Resolved
Comment thread internal/scanner/file_relink.go Resolved
Comment thread internal/scanner/file_relink.go Resolved
Comment thread internal/scanner/file_repo_relink.go Resolved
@coderabbitai coderabbitai Bot added the impact: data-loss User data deleted, corrupted, or unrecoverable label Nov 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 40a824b6-40dc-4dfe-b555-8278eb6ab5ab
Commits

Reviewing files that changed from the base of the PR and between b0ded7c and c677050.

Files selected for processing: 10

  • docs/architecture/missing-files.md
  • internal/chapterthumbs/marker_snapshots.go
  • internal/scanner/file_relink.go
  • internal/scanner/file_relink_db_test.go
  • internal/scanner/file_repo.go
  • internal/scanner/file_repo_marker_thumbnails.go
  • internal/scanner/file_repo_relink.go
  • internal/scanner/scanner.go
  • migrations/sql/20261112170646_keep_marker_thumbnails_across_renames.sql
  • migrations/sql/20261112172920_mark_retitle_stand_in_rows.sql

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment thread docs/architecture/missing-files.md Resolved
Comment thread internal/scanner/file_relink.go Resolved
Keep a renamed row's links only when matching the new path would resolve to
the title it already has: group and root claims, series siblings under the
observed root, then the group's provider IDs compared in the type's anchor
precedence. The comparison moves from metadata to catalog so both use it.

A stand-in reclaim that cannot be decided (database error, unreachable or
empty old root, fence lost twice) now fails the file for this scan instead of
writing it onto the stand-in.

Probe each library root once per lookup and stop once the pick is settled.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment thread internal/scanner/file_repo_relink.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 22a6c2a126

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/scanner/file_repo_relink.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Fence matcher link writes against the file identity they read. · file_relink.go:325

internal/scanner/file_relink.go:325
Major · Data Integrity & Integration · Heavy lift

Fence matcher link writes against the file identity they read.

RetitleMovedFile moves row F to the new path and clears its content link. A matcher job that already read F at the old path can still write its result. FileRepository.UpdateContentID updates by id only, so the stale write links F, now at the new path, to the old title.

The retitle fence covers only the scanner's own statement in moveRowToTitle. The matcher's skeleton write (internal/metadata/service.go:8352) does not check it. The worker guard at internal/metadata/worker.go:965 reads the scanned group, not the file row, so it does not detect the move. The search found no lock shared by scanner and matcher.

Make the link writes conditional on the identity the matcher read, such as file_path. Return an error when no row matches. The same concern applies to UpdateEpisodeLink (internal/scanner/file_repo.go:3960), which also keys only on the file ID. Both changes alter the write contracts, and several callers depend on them, so this needs a design change rather than a local edit.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0b17814-264c-4243-a40d-3293dcc34ea4
Commits

Reviewing files that changed from the base of the PR and between c677050 and 22a6c2a.

Files selected for processing: 7

  • docs/architecture/missing-files.md
  • internal/catalog/provider_identity.go
  • internal/metadata/service.go
  • internal/scanner/file_relink.go
  • internal/scanner/file_relink_db_test.go
  • internal/scanner/file_repo_relink.go
  • internal/scanner/scanner.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment thread internal/scanner/file_relink.go Resolved
A retitle moves the row's downloads for its old title onto the stand-in, so
they are refused and later deleted as they were with the missing row, and a
reverted rename brings them back. Without this a download kept serving a
file that now belongs to another title.

The series sibling lookup that decides whether a renamed row keeps its links
no longer counts the row itself.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Quick104

Copy link
Copy Markdown
Contributor Author

On the outside-diff finding in the latest CodeRabbit review ("Fence matcher link writes against the file identity they read"): confirmed, and not fixed in 5b384bd. A match job holding a snapshot from before a retitle can still link the moved row back to the old title, because UpdateContentID and UpdateEpisodeLink are fenced on the row id only. Matched files are not in the queue, so a bulk rename of a matched library is unlikely to hit it; a file being matched or retried at the moment it is renamed can. The narrow fix is a path fence on the matcher's link writes with a refused write re-run against the current row. That changes matching's write contract, so whether it goes in this PR or a follow-up is the maintainer's call.

🤖 Claude Code (claude-fable-5-2)

@silo-kody

silo-kody Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Copy link
Copy Markdown
Contributor Author

Decision on the matcher link-write fence: it goes in a follow-up PR, not this one. The race stays listed under Risks here until that lands.

🤖 Claude Code (claude-fable-5-2)

Comment thread internal/scanner/file_repo_relink.go Resolved
Comment thread internal/scanner/file_repo_relink.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b2a51a1-49ad-41fb-98e4-0f6e9936ef0d
Commits

Reviewing files that changed from the base of the PR and between 22a6c2a and 5b384bd.

Files selected for processing: 5

  • docs/architecture/missing-files.md
  • internal/scanner/file_relink.go
  • internal/scanner/file_relink_db_test.go
  • internal/scanner/file_repo.go
  • internal/scanner/file_repo_relink.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment thread internal/scanner/file_repo_relink.go Resolved
…file row

A download parked on a retitle's stand-in still pointed at the retitled row's
prepared artifact, so its remux or transcode could be served or prepared
again under the old title. Serving and preparing again now require the
artifact to belong to the download's file row.

An unlinked row that still carries downloads for a title now leaves a
stand-in for them, independent of the link comparison.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41771e8e69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/scanner/file_repo_relink.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 41771e8e69

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/scanner/file_repo_relink.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ea247c2-bd9c-40c9-828a-9d299a750647
Commits

Reviewing files that changed from the base of the PR and between 5b384bd and 41771e8.

Files selected for processing: 7

  • docs/architecture/missing-files.md
  • internal/downloads/parked_download_db_test.go
  • internal/downloads/service.go
  • internal/downloads/storage_reprepare.go
  • internal/scanner/file_relink_db_test.go
  • internal/scanner/file_repo_relink.go
  • scripts/ci/db-contracts.txt
Files skipped from review as they are similar to previous changes: 1

  • docs/architecture/missing-files.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment thread internal/downloads/storage_reprepare.go Resolved
PrepareDownloadAgain compared the artifact with the download as the caller
read it, so a download parked on a stand-in mid-request still requeued the
retitled row's artifact and became preparing. It now locks the download row
after the artifact and refuses before any requeue when the download's file
is no longer the one read or the artifact's own.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Quick104
Quick104 merged commit 98033bd into main Nov 13, 2026
21 checks passed
@Quick104
Quick104 deleted the fix/scanner-reuse-artifacts-on-rename branch November 13, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: data-loss User data deleted, corrupted, or unrecoverable impact: perf Unusable slowness on normal hardware priority: P1 Core-path bug; painful workaround — next after P0 size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant