backup

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	DeviceID   string          `json:"deviceId"`
	DeviceName string          `json:"deviceName,omitempty"`
	UpdatedAt  time.Time       `json:"updatedAt"`
	Settings   json.RawMessage `json:"settings"`
}

Envelope is the on-disk + wire shape. JSON tags match iOS's BackupEnvelope Codable; `Settings` is a json.RawMessage so the daemon never parses it.

type Meta

type Meta struct {
	DeviceID   string    `json:"deviceId"`
	DeviceName string    `json:"deviceName,omitempty"`
	UpdatedAt  time.Time `json:"updatedAt"`
}

Meta is the list-row form (no settings blob). Matches iOS's BackupMeta.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the per-device backup store. Filesystem-backed (one file per device under dir/), goroutine-safe via a single mutex.

func New

func New(dir string) (*Store, error)

New constructs the store, creating dir if missing. Returns error if dir can't be created (read-only fs, permission denied).

func (*Store) Get

func (s *Store) Get(deviceID string) *Envelope

Get returns the full envelope for one device, or nil if no backup exists.

func (*Store) List

func (s *Store) List() []Meta

List returns metadata for every stored backup, newest first. Missing dir entries are silently skipped (concurrent delete on another device).

func (*Store) Put

func (s *Store) Put(deviceID, deviceName string, settings json.RawMessage) (time.Time, error)

Put upserts the calling device's backup. Atomic write (tmp + rename) so a crash mid-write never leaves a partial file. deviceID is the key; the settings blob is stored verbatim.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL