pub fn strip_temporary_suffix(name: &[u8]) -> Option<&[u8]>Expand description
The target a temporary file was named after, if name is one of ours.
A process killed outright cannot clean up after itself, and on the unlock
and lock paths the residue holds a decrypted secret. lock promises
that no plaintext of a selected path survives it, so it has to recognise
residue — and, because it deletes what it recognises, it has to recognise it
narrowly. Returning the target rather than a yes/no is what lets the caller
add the second condition that makes deletion safe: only sweep residue whose
target the declaration actually selects.
Deliberately exact. The marker must be followed by exactly [RANDOM_LEN]
bytes of lowercase hex — the only kind [temporary_name] emits — then
.tmp, and something must precede the marker, because these names are always
built from a target’s own name. A file a user happens to have called
notes.git-xcrypt-draft.tmp is not matched, and neither is
notes.git-xcrypt-DEADBEEFDEADBEEF.tmp.