Documentation
¶
Overview ¶
Package prefetchstore ports storage.ts: a generic, content-hash-deduped file store. link.go uses it to cache a link preview's thumbnail locally (Config.values.prefetchStorage) rather than showing it as a direct link to the original, unauthenticated remote URL - avoiding leaking every viewer's IP to arbitrary third-party image hosts on each render, and deduping identical thumbnails fetched from different messages/channels down to one file on disk.
Unrelated to internal/uploads (token-authed, expiring, user-uploaded files) despite both living under a data directory - this store has no auth or expiration concept, just content-addressed dedup, and its directory is wiped wholesale on every server start/stop (cmd/relay/ start.go's clearStorageDir, already the Go port of storage.ts's own emptyDir - that part of Node's Storage class was already ported, only store()/dereference() were missing).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store mirrors storage.ts's Storage class.
func (*Store) Dereference ¶
Dereference mirrors Storage.dereference: drop one reference to url (previously returned by Save), deleting the underlying file once nothing references it anymore.
func (*Store) Save ¶
Save mirrors Storage.store: hash data, and write it under dir/<hash[:2]>/<hash[2:4]>/<hash[4:]>.<extension> unless a file with that exact content (and thus exact hash) is already stored, bumping its reference count either way. Returns the "storage/aa/bb/rest.ext" URL the client is served this content under (relative to the app's own static file serving, matching Node's own url shape).