StructuredEntryIDKey is the ONE rule for what a structured entry's stored id means as a timeline id (BUG-2783, BUG-2788). It returns the key the entry claims and whether its raw id is usable at all: - a raw id that is empty, not valid UTF-8, or carries a NUL is unusable; - a raw id that could be co
(raw, prefix string)
| 33 | // are exactly the ones the timeline would otherwise have put on its |
| 34 | // index-dependent positional fallback, and no others. |
| 35 | func StructuredEntryIDKey(raw, prefix string) (key string, usable bool) { |
| 36 | if raw == "" || !utf8.ValidString(raw) || strings.ContainsRune(raw, 0) { |
| 37 | return "", false |
| 38 | } |
| 39 | if uuid.Validate(raw) == nil || hasStructuredEntryPrefix(raw) { |
| 40 | return prefix + ":" + raw, true |
| 41 | } |
| 42 | return raw, true |
| 43 | } |
| 44 | |
| 45 | // Why a UUID-SHAPED raw id is diverted. This reasoning is BUG-2783's, |
| 46 | // unchanged; it moved here from the timeline's looksLikeRowID with the rule |