When multiple indexed assets have matching asset identifiers, increase the content hash size until it doesn't collide. Fixes #537
Detailed description
There are certain edge cases where multiple assets can end up colliding with each other in the asset path, for example:
Multiple copies of the same file in different directories but with the same basename
An odd edge case where the link resolver sees the file in both its relative and absolute path
Different asset files of the same name which happen to collide in their shorthash (very unlikely but still possible!)
Each of those cases could cause the link resolver to add multiple different asset items with the same asset identifier, which would cause the link resolver to fail.
This change modifies the asset identifier in two ways:
A shorthash of the full file path is used as a "directory"
The file's shorthash increases the digit count if the new identifier would cause a collision with something at a different path location
The file path shorthash cuts down on the possibility that different files with the same md5sum will swap URLs between site reindexes; the possibility still isn't 0, but it's way less likely now.
Developer/user impact
This change means that existing external links to asset files will probably become invalid, but asset links aren't intended to be stable to begin with.
Summary
When multiple indexed assets have matching asset identifiers, increase the content hash size until it doesn't collide. Fixes #537
Detailed description
There are certain edge cases where multiple assets can end up colliding with each other in the asset path, for example:
Each of those cases could cause the link resolver to add multiple different asset items with the same asset identifier, which would cause the link resolver to fail.
This change modifies the asset identifier in two ways:
The file path shorthash cuts down on the possibility that different files with the same md5sum will swap URLs between site reindexes; the possibility still isn't 0, but it's way less likely now.
Developer/user impact
This change means that existing external links to asset files will probably become invalid, but asset links aren't intended to be stable to begin with.
Test plan
See
dupe assets.md
Got a site to show off?