Skip to content

Re-link moved/renamed files and refresh LastSeenOnNas on every crawl #35

Closed

Description

@bitbiter-dev

Problem

A file that is moved or renamed on the NAS keeps its old FilePath in the database.

  • IdempotencyCheckMiddleware finds the existing row by (StorageConfigId, ContentHash) and returns without doing anything.
  • LastSeenOnNas is set only at first ingest (PersistenceMiddleware, PairedMovResolver) and never refreshed.

Once originals are served (#44), every moved photo will 404. Reconciliation (#33, #34, #37) also needs LastSeenOnNas to be current. This is why the issue is pulled ahead of the rest of Epic 4.

Behaviour

In the idempotency step, when an active row with the same (StorageConfigId, ContentHash) exists:

Situation Action
Same FilePath Refresh LastSeenOnNas.
Different FilePath, and the stored path no longer exists under the config root Moved: update FilePath to the new path and refresh LastSeenOnNas.
Different FilePath, and the stored path still exists Duplicate copy: leave the row alone. #36 reports it. Do not ingest a second row; the partial unique index forbids one.

In every case, ingestion of that item stops there: no metadata extraction, no proxy regeneration.

Proxies need no move. Their directory is keyed by content and config, not by path (IProxyDirectoryStrategy). A Live Photo pair moved together keeps its PairedAssetId link, because each half is matched by its own hash.

Acceptance

  • A moved file updates FilePath on its existing row. Its Id, its interactions and its proxies are unchanged.
  • A re-crawled, unchanged file refreshes LastSeenOnNas and nothing else.
  • A second copy at another path leaves the row unchanged and logs it at debug level.
  • The persistence write goes through IUnitOfWork as it does today. A concurrent consumer racing on the same hash must not throw. PersistenceMiddleware already tolerates the unique-index race; mirror that.
  • Tests at the middleware seam, with MockFileSystem for path existence.
  • scripts/mutation-changed.sh at 100%.

Activity

  1. changed the title [-]4.3 Detect moved/renamed files via content_hash[/-] [+]Detect moved/renamed files via content_hash[/+] on May 12, 2026
  2. modified the milestones: Epic 4: NAS Reconciliation & Data Health, on May 12, 2026
  3. added
    ready-for-agentFully specified, ready for an AFK agent
    and removed
    needs-triageMaintainer needs to evaluate this issue
    on Oct 16, 2026
  4. changed the title [-]Detect moved/renamed files via content_hash[/-] [+]Re-link moved/renamed files and refresh LastSeenOnNas on every crawl[/+] on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentFully specified, ready for an AFK agentv1.0Required for the v1.0 release

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions