chore: avoid known file signatures in datatypeId #155
Merged
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.
This is just a performance optimization for the Mapeo indexer so that it
avoids trying to parse files that are not Mapeo Docs. For example, a
hypercore might have PNG files written to it, which is prefixed by '89
50 4E 47 0D 0A 1A 0A'. If we used this as a dataTypeId then the indexer
would think any PNGs in the core are a Mapeo datatype and try to parse
them. It would fail and just be ignored, but trying to parse would have
a performance cost.
This is a check in the build script that will throw an error if a new
dataType is added that matches one of the known file signature prefixes.
In some cases we don't check against the whole file signature - we just
avoid starting data type IDs with byte(s) that are common in file
signatures.