| 1 | package session |
| 2 | |
| 3 | import ( |
| 4 | "reasonix/internal/sessioncontent" |
| 5 | "reasonix/internal/sessioninbox" |
| 6 | "reasonix/internal/store" |
| 7 | ) |
| 8 | |
| 9 | func collectInboxContentRefs(sessionDir string) []sessioncontent.Ref { |
| 10 | refs, _ := collectInboxContentRefsChecked(sessionDir) |
| 11 | return refs |
| 12 | } |
| 13 | |
| 14 | func collectInboxContentRefsChecked(sessionDir string) ([]sessioncontent.Ref, error) { |
| 15 | return sessioninbox.FrozenContentRefs(store.SessionInboxDir(sessionDir)) |
| 16 | } |
| 17 | |
| 18 | //nolint:unused // The history export layer deduplicates its content closure with this key. |
| 19 | func contentRefKey(ref sessioncontent.Ref) string { |
| 20 | return ref.Digest + ":" + itoa64(ref.Bytes) + ":" + ref.IndexDigest |
| 21 | } |
| 22 | |
| 23 | //nolint:unused // Kept allocation-free for contentRefKey in the history export layer. |
| 24 | func itoa64(n int64) string { |
| 25 | if n == 0 { |
| 26 | return "0" |
| 27 | } |
| 28 | var buf [20]byte |
| 29 | i := len(buf) |
| 30 | neg := n < 0 |
| 31 | if neg { |
| 32 | n = -n |
| 33 | } |
| 34 | for n > 0 { |
| 35 | i-- |
| 36 | buf[i] = byte('0' + n%10) |
| 37 | n /= 10 |
| 38 | } |
| 39 | if neg { |
| 40 | i-- |
| 41 | buf[i] = '-' |
| 42 | } |
| 43 | return string(buf[i:]) |
| 44 | } |
| 45 |