Documentation
¶
Index ¶
- func ComputeHash(data []byte) string
- func ComputeJSONHash(v interface{}) (string, []byte, error)
- type Content
- type FileMeta
- type FileMetaCatalog
- type FileType
- type HAMTNode
- type Index
- type LeafEntry
- type ObjectType
- type RepoConfig
- type Snapshot
- type SnapshotCatalog
- type SnapshotSummary
- type SourceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeHash ¶
ComputeHash computes the SHA-256 hash of the given data and returns it as a hex string.
func ComputeJSONHash ¶
ComputeJSONHash computes the SHA-256 hash of the JSON representation of the object. This uses encoding/json which sorts map keys, providing a canonical form for basic structs.
Types ¶
type Content ¶
type Content struct {
Type ObjectType `json:"type"` // "content"
Size int64 `json:"size"`
Chunks []string `json:"chunks,omitempty"` // List of "chunk/<sha256>"
DataInlineB64 []byte `json:"data_inline_b64,omitempty"` // For small files
}
Content represents a file's content as a list of chunks Object key: content/<sha256>
type FileMeta ¶
type FileMeta struct {
Version int `json:"version"`
FileID string `json:"fileId"` // Google Drive file ID (HAMT key)
Name string `json:"name"`
Type FileType `json:"type"` // "file" or "folder"
Parents []string `json:"parents"` // List of "filemeta/<sha256>" refs (NOT raw IDs)
Paths []string `json:"paths"`
ContentHash string `json:"content_hash"` // SHA256 of the file content
Size int64 `json:"size"`
Mtime int64 `json:"mtime"` // Unix timestamp
Owner string `json:"owner"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
FileMeta represents immutable file metadata Object key: filemeta/<sha256>
type FileMetaCatalog ¶
FileMetaCatalog is the on-disk format for index/filemeta. Keys are store refs ("filemeta/<hash>"), values are the full FileMeta.
type FileType ¶
type FileType string
FileType defines the generic type of the file (e.g. generic file, folder, symlink)
type HAMTNode ¶
type HAMTNode struct {
Type ObjectType `json:"type"` // "internal" or "leaf"
Bitmap uint32 `json:"bitmap,omitempty"`
Children []string `json:"children,omitempty"` // ["node/<sha256>", ...]
Entries []LeafEntry `json:"entries,omitempty"`
}
HAMTNode represents a node in the Merkle-HAMT Object key: node/<sha256>
type Index ¶
type Index struct {
LatestSnapshot string `json:"latest_snapshot"` // "snapshot/<sha256>"
Seq int `json:"seq"`
}
Index represents a pointer to the latest snapshot Key: index/latest
type LeafEntry ¶
type LeafEntry struct {
Key string `json:"key"` // FileID
FileMeta string `json:"filemeta"` // "filemeta/<sha256>"
}
LeafEntry represents an entry in a Leaf node
type ObjectType ¶
type ObjectType string
ObjectType defines the type of the object in the system
const ( ObjectTypeContent ObjectType = "content" ObjectTypeInternal ObjectType = "internal" ObjectTypeLeaf ObjectType = "leaf" )
type RepoConfig ¶
type RepoConfig struct {
Version int `json:"version"`
Created string `json:"created"` // ISO8601
Encrypted bool `json:"encrypted"`
}
RepoConfig is the repository marker written by "init". It is stored as plaintext at key "config" so it can be read without the encryption key. Key: config
type Snapshot ¶
type Snapshot struct {
Version int `json:"version"`
Created string `json:"created"` // ISO8601
Root string `json:"root"` // "node/<sha256>"
Seq int `json:"seq"`
Source *SourceInfo `json:"source,omitempty"`
Meta map[string]string `json:"meta,omitempty"`
Tags []string `json:"tags,omitempty"`
ChangeToken string `json:"change_token,omitempty"`
}
Snapshot represents a backup checkpoint Object key: snapshot/<sha256>
type SnapshotCatalog ¶
type SnapshotCatalog struct {
Snapshots []SnapshotSummary `json:"snapshots"`
}
SnapshotCatalog is the on-disk format for index/snapshots.
type SnapshotSummary ¶
type SnapshotSummary struct {
Ref string `json:"ref"` // "snapshot/<hash>"
Seq int `json:"seq"`
Created string `json:"created"` // ISO8601
Root string `json:"root"` // "node/<hash>"
Source *SourceInfo `json:"source,omitempty"`
Tags []string `json:"tags,omitempty"`
ChangeToken string `json:"change_token,omitempty"`
}
SnapshotSummary is a lightweight representation of a snapshot stored in the snapshot catalog index. It contains enough metadata for listing, filtering, and finding the previous snapshot without having to fetch the full object.
type SourceInfo ¶
type SourceInfo struct {
Type string `json:"type"` // e.g. "gdrive", "local"
Account string `json:"account,omitempty"` // Google account email, hostname, etc.
Path string `json:"path,omitempty"` // root folder ID, filesystem path, etc.
}
SourceInfo describes the origin of a backup snapshot. It is stored as a first-class field on the snapshot so that forget policies can group by source identity (Type + Account + Path).