Repository navigation
impl(core): multiple filepaths per media file (media_filepath model, md5checksum) - #94
Draft
andykais-ai wants to merge 2 commits into
Draft
andykais-ai wants to merge 2 commits into
andykais-ai wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
media_filepathmodel (media_filepath::media_file_id→media_file), with one row per known path and a unique constraint onfilepath.media_file.filepathstays as a denormalized reference to the first filepath found.media_file::md5checksum. sha256 and md5 are computed in a single file read and exposed onmedia_filein all API responses. Existing rows staynullafter migration, and the value is backfilled when a duplicate path is added for that media file.media_filepathfrommedia_file, and renames the oldmedia_filepathindex onmedia_file(filepath)tomedia_file_filepath, because SQLite tables and indexes share a namespace.media.create:media_filepathrow 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 thatmedia_reference_tagcould store its filepath source so tags can be merged better.media_file.filepath/filenameare swapped to the new path and themedia_filepathrow is rewritten in place. There is no orphan tracking.MediaAlreadyExistsError.duplicate.media.get({filepath})and the searchfilepathfilter so they match any known filepath.media.getand the single-media responses now includefilepaths, andmedia.deleteremoves the filepath rows.Note:
media.createno longer throwsDuplicateMediaErroron a duplicate checksum. It returns the existing media instead. The error class is still exported.Vision Testing
test/media_filepath.test.ts:created: 1, duplicate: 1media_filepathrow, and that the migrated schema matches a freshly seeded one.mainfrom ffmpeg duration/keypoint precision. The lint, core and CLI type checks, web build and CLI tests also pass.