Repository navigation
fix: index files whose contentSize has units - #40
Merged
Merged
Conversation
schema.org contentSize is text, e.g. "14384 bytes". Coercing it with + gave NaN, so prisma.file.create failed and the file rows were lost. Prefer the size in the OCFL inventory; fall back to the leading integer of contentSize, then -1.
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
schema.org
contentSizeis text (its example is"25 KB"). The structural indexer coerced it with+, so"14384 bytes"becameNaNandprisma.file.createfailed for every file in the crate. Prisma's error reports "Argumententityis missing", which is misleading. The entity rows were saved; only the file rows were lost.The inventory now wins over
contentSize, because it is the real size of the stored file.contentSizewith other units is taken at face value:"25 KB"→ 25. That only applies to files missing from OCFL, where the size is a best guess anyway.Evidence
On the dev server, crate
arcp://name,hdl10.25949~24769173.v1lost all 1069 file rows.New tests in
src/indexer/structural.test.tsrunStructuralIndexer.indexagainst a fakeCrateObjectand the test database:contentSize: "14384 bytes"→ no file rowcontentSize: "14384 bytes"→ no file rowcontentSize: "unknown"→ no file row (expected -1)contentSize), -1. Full suite: 166 passed.Merge Danger
Door: two-way
Only the stored
sizechanges. Re-runningpnpm indexrebuilds the rows.Blast Radius: small
File sizes shown by the API can change where a crate's numeric
contentSizedisagreed with the file in OCFL. The search indexer doesn't readcontentSize.