state

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package state is the daemon's SQLite state store (spec §4.3).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backlog

type Backlog struct {
	Files         int
	Bytes         int64
	OldestUnacked time.Time // min last_ack_at among backlog files; zero if none ever acked
	LastAck       time.Time // max last_ack_at over all files
}

Backlog summarises unacked work.

type DB

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

DB wraps the SQLite connection pool.

func Open

func Open(path string) (*DB, error)

Open creates the file (0600), its parent directory (0700) and the schema.

func (*DB) AddSkipped

func (d *DB) AddSkipped(ctx context.Context, s Skipped) error

AddSkipped records an entry; recording it again is a no-op.

func (*DB) Backlog

func (d *DB) Backlog(ctx context.Context) (Backlog, error)

Backlog counts append files with acked_offset < size_seen and snapshot files flagged with size_seen = -1 (changed, not acked).

func (*DB) Close

func (d *DB) Close() error

Close closes the database.

func (*DB) Delete

func (d *DB) Delete(ctx context.Context, relPath, headHash string) error

Delete removes a row; missing rows are not an error.

func (*DB) Get

func (d *DB) Get(ctx context.Context, relPath, headHash string) (File, bool, error)

Get returns the row for (relPath, headHash).

func (*DB) HasSkipped

func (d *DB) HasSkipped(ctx context.Context, relPath, headHash string) (bool, error)

HasSkipped reports whether the file has a skipped entry (its spool copy must be kept).

func (*DB) List

func (d *DB) List(ctx context.Context) ([]File, error)

List returns all rows ordered by key.

func (*DB) ListSkipped

func (d *DB) ListSkipped(ctx context.Context) ([]Skipped, error)

ListSkipped returns all skipped entries ordered by path and offset.

func (*DB) Put

func (d *DB) Put(ctx context.Context, f File) error

Put upserts by (rel_path, head_hash).

func (*DB) ResetAcks

func (d *DB) ResetAcks(ctx context.Context) error

ResetAcks forgets everything the server acknowledged (offsets, snapshot hashes, the resume marker) so the whole history is sent again to a new device. Spool paths and file ids stay.

func (*DB) SetSetting

func (d *DB) SetSetting(ctx context.Context, key, value string) error

SetSetting upserts a setting.

func (*DB) Setting

func (d *DB) Setting(ctx context.Context, key string) (string, bool, error)

Setting reads a setting.

type File

type File struct {
	RelPath, HeadHash string
	Kind              protocol.Kind
	AckedOffset       int64
	ContentHash       string
	FileID            string
	SizeSeen          int64
	SpoolPath         string
	OriginalGone      bool
	LastAckAt         time.Time // zero if never
	DeviceScoped      bool      // the server answered conflict: send with scope "device"
}

File is one row of the files table.

type Skipped

type Skipped struct {
	RelPath, HeadHash string
	Offset, Length    int64
	SHA256            string
}

Skipped is a line (or snapshot, Offset 0) too large for the protocol, left out of the upload.

Jump to

Keyboard shortcuts

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