Documentation
¶
Overview ¶
Package store manages a volume's local on-disk state: a content-addressed blob store, the per-device journals, and small JSON state files. Everything a volume needs works offline; the remote is only used to exchange blobs and journals.
Layout under <beardrive home>/volumes/<volume>/:
blobs/<aa>/<sha256> content-addressed file contents (immutable) journal/<device>.jsonl per-device op logs (own + cached copies of peers) state.json what is currently materialized in the folder sync.json lamport clock + push cursor lock flock guarding cycles
Index ¶
- func WriteFileAtomic(path string, data []byte, mode os.FileMode) error
- func WriteJSONAtomic(path string, v any) error
- type CachedFile
- type Store
- func (s *Store) AllOps() ([]journal.Op, error)
- func (s *Store) AppendOps(device string, ops []journal.Op) error
- func (s *Store) BlobPath(sum string) string
- func (s *Store) DeviceOps(device string) ([]journal.Op, error)
- func (s *Store) Devices() ([]string, error)
- func (s *Store) Dir() string
- func (s *Store) HasBlob(sum string) bool
- func (s *Store) JournalPath(device string) string
- func (s *Store) LoadCache(mountID string) (map[string]CachedFile, error)
- func (s *Store) LoadSync() (SyncState, error)
- func (s *Store) Lock() (func() error, error)
- func (s *Store) OpenBlob(sum string) (*os.File, error)
- func (s *Store) PutBlobBytes(b []byte) (string, int64, error)
- func (s *Store) PutBlobFile(path string) (string, int64, error)
- func (s *Store) PutBlobReader(r io.Reader) (string, int64, error)
- func (s *Store) SaveCache(mountID string, c map[string]CachedFile) error
- func (s *Store) SaveSync(st SyncState) error
- type SyncState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteFileAtomic ¶
WriteFileAtomic writes data via a temp file in the same directory + rename.
func WriteJSONAtomic ¶
WriteJSONAtomic writes v as JSON via temp-file + rename.
Types ¶
type CachedFile ¶
type CachedFile struct {
Blob string `json:"blob"`
Size int64 `json:"size"`
Mode uint32 `json:"mode"`
MTimeNS int64 `json:"mtime_ns"`
}
CachedFile records what beardrive last wrote to / observed in the working folder for a path. Size+MTimeNS make change detection cheap; Blob ties it back to content. The cache is per mount (one volume can be materialized into several folders, each with its own stat fingerprints).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) JournalPath ¶
func (*Store) Lock ¶
Lock takes an exclusive flock for the volume, serializing sync cycles between the daemon and one-shot commands. Blocks until acquired.
func (*Store) PutBlobReader ¶
PutBlobReader streams r into the blob store, returning its sha256 and size.