Skip to main content

cloud_path_names_blob

Function cloud_path_names_blob 

Source
pub fn cloud_path_names_blob(cloud_path: &str, blob_id: &str) -> bool
Expand description

Whether the readable cloud_path a consumer supplied names the blob blob_id — what coven requires of a Replaceable blob’s key on a browsable home, and what a hashed key gets for free by carrying the id itself.

The path’s file name (its last /-segment), with any extension stripped, must be the blob id or end with -{blob_id}:

covers/Live at Leeds/cover-0ef7a1c9.jpg   ✓   stem `cover-0ef7a1c9` ends with -0ef7a1c9
covers/Live at Leeds/0ef7a1c9.jpg         ✓   stem is the blob id
covers/Live at Leeds/cover.jpg            ✗   names no blob

A blob id names one immutable byte-string and is minted fresh for every stored blob, so a path carrying it moves whenever the bytes do — which is what leaves a replaced blob’s object standing at its own key instead of overwritten.

The - delimiter is what makes this a near-injective mapping where a bare substring test would not be: without it, blob 1 would satisfy blob 11’s path and the two could be keyed at one object. Two ids can still collide if one is a --suffix of the other AND the consumer builds paths that land on the same file name — which ids drawn from any of the usual generators do not do.