Documentation
¶
Index ¶
- Constants
- type FSStorage
- func (fs *FSStorage) Close() error
- func (fs *FSStorage) CompactChunks(ctx context.Context, reachable map[core.Hash]bool, dryRun bool) (storage.CompactReport, error)
- func (fs *FSStorage) DeleteChunk(ctx context.Context, hash core.Hash) error
- func (fs *FSStorage) DeleteRef(ctx context.Context, name string) error
- func (fs *FSStorage) DeleteSnapshot(ctx context.Context, id core.SnapshotID) error
- func (fs *FSStorage) GetChunk(ctx context.Context, hash core.Hash) (*core.Chunk, error)
- func (fs *FSStorage) GetConfig(ctx context.Context) (*core.Config, error)
- func (fs *FSStorage) GetIndex(ctx context.Context) (*core.Index, error)
- func (fs *FSStorage) GetPreview(ctx context.Context, hash core.Hash, size int) ([]byte, error)
- func (fs *FSStorage) GetRef(ctx context.Context, name string) (*core.Reference, error)
- func (fs *FSStorage) GetSnapshot(ctx context.Context, id core.SnapshotID) (*core.Snapshot, error)
- func (fs *FSStorage) HasChunk(ctx context.Context, hash core.Hash) (bool, error)
- func (fs *FSStorage) ListChunks(ctx context.Context) ([]core.Hash, error)
- func (fs *FSStorage) ListRefs(ctx context.Context, prefix string) ([]*core.Reference, error)
- func (fs *FSStorage) ListSnapshots(ctx context.Context, opts *storage.ListOptions) ([]*core.SnapshotSummary, error)
- func (fs *FSStorage) PutChunk(ctx context.Context, chunk *core.Chunk) error
- func (fs *FSStorage) PutPreview(ctx context.Context, hash core.Hash, size int, data []byte) error
- func (fs *FSStorage) PutSnapshot(ctx context.Context, snapshot *core.Snapshot) error
- func (fs *FSStorage) SetCompressionConfig(enabled bool, level int) error
- func (fs *FSStorage) SetConfig(ctx context.Context, config *core.Config) error
- func (fs *FSStorage) SetIndex(ctx context.Context, index *core.Index) error
- func (fs *FSStorage) SetRef(ctx context.Context, name string, ref *core.Reference) error
Constants ¶
const ( DriftDir = storage.DriftDir ChunksDir = storage.ChunksDir SnapshotsDir = storage.SnapshotsDir ManifestsDir = storage.ManifestsDir RefsDir = storage.RefsDir PreviewsDir = storage.PreviewsDir HeadsDir = storage.HeadsDir TagsDir = storage.TagsDir LogsDir = storage.LogsDir HeadFile = storage.HeadFile IndexFile = storage.IndexFile ConfigFile = storage.ConfigFile PacksDir = storage.PacksDir )
Layout constants are re-exported from the storage interface package so existing references within the filesystem backend continue to work. The single source of truth is storage/layout.go; keeping the canonical constants in the storage package lets the remote package depend on storage only, without reaching into a concrete backend.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSStorage ¶
type FSStorage struct {
// contains filtered or unexported fields
}
func NewFSStorage ¶
func (*FSStorage) CompactChunks ¶
func (fs *FSStorage) CompactChunks(ctx context.Context, reachable map[core.Hash]bool, dryRun bool) (storage.CompactReport, error)
CompactChunks implements storage.ChunkCompactor for the filesystem backend.
func (*FSStorage) DeleteChunk ¶
DeleteChunk removes a loose chunk from disk and evicts it from the in-memory cache. It is idempotent: a missing file is not an error.
DeleteChunk only removes loose chunks; packed chunks are not affected and must be reclaimed via CompactChunks.
func (*FSStorage) DeleteSnapshot ¶
DeleteSnapshot removes a snapshot and its manifest from disk. It is idempotent: a missing file is not an error.
func (*FSStorage) GetConfig ¶
GetConfig reads the drift configuration from the config file. The file is unmarshaled on top of DefaultConfig(), so fields absent from the JSON retain their default values rather than Go zero values. This matters for bool fields like Compression (zero=false vs default=true) and for int fields where 0 is not a valid size.
func (*FSStorage) GetPreview ¶
GetPreview is a noop stub (Phase 1). Returns ErrNotFound so callers can distinguish "no preview" from "preview feature disabled"; matches the memory backend's behavior.
func (*FSStorage) GetSnapshot ¶
GetSnapshot reads a snapshot from disk and verifies its integrity.
Memory layout: the file is read in full (io.ReadAll), unmarshalled into a SnapshotProto, then the proto is re-marshaled with IdHash cleared for the BLAKE3 integrity check. Peak memory is therefore roughly raw + decoded + re-marshaled. To minimize the peak we:
- drop the raw buffer reference before re-marshaling (the decoder has already produced an independent copy of the message);
- run the hash incrementally over the re-marshaled bytes via a streaming blake3 hasher and drop each chunk immediately, so the re-marshaled buffer does not need to live alongside the decoded message.
google.golang.org/protobuf (v1.36.x) does not expose a reader-based streaming decoder (proto.NewDecoder was removed in the github.com/golang/protobuf v1.5.0 shim), so the initial io.ReadAll is unavoidable without a much larger refactor.
func (*FSStorage) ListChunks ¶
func (*FSStorage) ListSnapshots ¶
func (fs *FSStorage) ListSnapshots(ctx context.Context, opts *storage.ListOptions) ([]*core.SnapshotSummary, error)
ListSnapshots lists all snapshots via lightweight manifests, sorted by timestamp descending, with optional limit/offset pagination. Returns snapshot summaries without file lists — call GetSnapshot for full details.
Snapshots without a manifest (e.g. created before manifests were introduced) fall back to reading the full snapshot file and backfilling a manifest so subsequent listings are fast.
func (*FSStorage) PutChunk ¶
PutChunk stores a chunk to disk. The chunk data is verified against its declared hash before persisting, so a caller-supplied mismatch can never reach disk and cause later GetChunk integrity failures. If the chunk already exists (loose or in a pack), PutChunk is a no-op.
Writes are not verified by re-reading; on-disk corruption is detected on the subsequent GetChunk via the BLAKE3 integrity check.
func (*FSStorage) PutPreview ¶
PutPreview is a noop stub (Phase 1).
func (*FSStorage) PutSnapshot ¶
PutSnapshot writes a snapshot and its lightweight manifest to disk.
func (*FSStorage) SetCompressionConfig ¶
SetCompressionConfig applies the compression settings to the backend. enabled toggles zstd compression of chunk payloads; level is the zstd command-line level (1-19) and is converted to the library's EncoderLevel internally. This satisfies storage.ConfigStorer so porcelain can apply config uniformly across backends without type-asserting to FSStorage.