Skip to content

impl(core): multiple filepaths per media file (media_filepath model, md5checksum) - #94

Draft
andykais-ai wants to merge 2 commits into
mainfrom
cursor/media-filepaths-21f3
Draft

andykais-ai wants to merge 2 commits into
mainfrom
cursor/media-filepaths-21f3

Conversation

@andykais-ai

Copy link
Copy Markdown
Collaborator

Summary

  • implements a media_filepath model (media_filepath::media_file_id → media_file), with one row per known path and a unique constraint on filepath. media_file.filepath stays as a denormalized reference to the first filepath found.
  • implements media_file::md5checksum. sha256 and md5 are computed in a single file read and exposed on media_file in all API responses. Existing rows stay null after migration, and the value is backfilled when a duplicate path is added for that media file.
  • implements migration v12. It adds the column, creates and backfills media_filepath from media_file, and renames the old media_filepath index on media_file(filepath) to media_file_filepath, because SQLite tables and indexes share a namespace.
  • improves duplicate-checksum creation, used by ingest and by media.create:
    • if the original path exists, a new media_filepath row is added for the existing media file. Media info and tags are applied like an update, in the same transaction. Tags are only added, never replaced, and a TODO notes that media_reference_tag could store its filepath source so tags can be merged better.
    • if the original path is missing, media_file.filepath/filename are swapped to the new path and the media_filepath row is rewritten in place. There is no orphan tracking.
    • re-adding a known path throws MediaAlreadyExistsError.
  • improves ingest stats: linked or moved duplicates are counted as duplicate.
  • improves media.get({filepath}) and the search filepath filter so they match any known filepath. media.get and the single-media responses now include filepaths, and media.delete removes the filepath rows.

Note: media.create no longer throws DuplicateMediaError on a duplicate checksum. It returns the existing media instead. The error class is still exported.

Vision Testing

  • new test/media_filepath.test.ts:
    • linking a duplicate (merged tags and media info, md5 value)
    • the duplicate guard
    • get and search by a secondary path
    • swapping when the original path is missing
    • delete cleanup
    • ingest of two identical files, which reports created: 1, duplicate: 1
  • migration test now covers v1 → v12. It checks that every existing media file has its media_filepath row, and that the migrated schema matches a freshly seeded one.
  • core suite: all tests pass except the 4 tests (5 steps) that already fail on main from ffmpeg duration/keypoint precision. The lint, core and CLI type checks, web build and CLI tests also pass.
Open in Web Open in Cursor 

cursoragent and others added 2 commits October 13, 2026 22:02
media files can now have multiple filepaths. creating media with a duplicate
checksum attaches the new filepath to the existing media file and applies its
media info and tags as an update

Co-authored-by: kaisea.rpi <kaisea.rpi@gmail.com>
…cate filepaths absolutely

Co-authored-by: kaisea.rpi <kaisea.rpi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants