Skip to content

chore(import): clean up import runs whose source directory no longer exists #5529

Description

@JakobLichterfeld

Context

Follow-up to #5519. Import runs are keyed by a hashed source_key derived from the
import directory path. Checkpoint.start_run/2 deletes previous non-running runs for
the same source key
before inserting a new one, so retention is bounded per directory.

Problem

If the import directory is renamed or moved, its runs (plus cascaded file checkpoints and
rejections) are orphaned under the old source key and are never cleaned up. The data
volume is small and bounded (at most one lingering run per abandoned path), so this is
cosmetic — but the rows accumulate forever with no way to remove them short of manual SQL.

Suggested change

Options, roughly in order of preference:

  1. On Import startup (read_directory), delete non-:running runs whose source_key
    differs from the current one — the import feature only ever serves a single directory,
    so runs for other keys are unreachable by definition.
  2. Alternatively, a periodic or startup-time sweep that removes runs older than some
    generous threshold.

Either way, import_file_checkpoints and import_rejections follow via the existing
on_delete: :delete_all references.

🤖Issue drafted with Claude Code (Fable 5 high) — sponsored by Claude for Open Source

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions