types

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRemoteFileNotFound = errors.New("remote file not found")

ErrRemoteFileNotFound reports that the peer no longer has the file (gRPC NotFound), not a transient fetch failure. On-demand reads map it to EOF and map stalls to EIO. It lives here so the filesystem package avoids a gRPC import.

Functions

func AttrToStat

func AttrToStat(attr *keibidrop.Attr) *fuse.Stat_t

AttrToStat converts a protobuf Attr back to a FUSE Stat_t.

func NanoToTimespec

func NanoToTimespec(ns uint64) fuse.Timespec

NanoToTimespec converts nanoseconds since Unix epoch to a fuse.Timespec.

func StatToAttr

func StatToAttr(stat *fuse.Stat_t) *keibidrop.Attr

StatToAttr converts a FUSE Stat_t to a protobuf Attr.

Types

type ChunkHashReceiver added in v0.3.6

type ChunkHashReceiver interface {
	Recv() (chunkIndex uint64, hash uint64, err error)
}

ChunkHashReceiver streams (chunkIndex, hash) pairs from a peer's GetChunkHashes RPC.

type ChunkHasher added in v0.3.6

type ChunkHasher interface {
	GetChunkHashes(ctx context.Context, path string, chunkSize, fromChunk, count uint64) (ChunkHashReceiver, error)
}

ChunkHasher marks providers that support the GetChunkHashes RPC. Callers type-assert and fall back when a provider (older peer, test fake) lacks it.

type FileAction

type FileAction int

FileAction identifies the type of a local filesystem event.

const (
	Unknown FileAction = iota
	AddDir
	AddFile
	RemoveDir
	RemoveFile
	EditDir
	EditFile
	RenameFile
	RenameDir
	// CancelPendingNotify never reaches the wire: it tells the notify worker
	// to drop a queued ADD/EDIT for the path. Emitted when an acceptance
	// replaces local content — the queued announce describes bytes that no
	// longer exist, and its flush-time attr refresh would stamp the PEER'S
	// content with a fresh local mtime and bounce it back as "newer".
	CancelPendingNotify
)

type FileEvent

type FileEvent struct {
	Path    string // Relative path in the FS; the new path for renames.
	OldPath string // Source path for renames.
	Action  FileAction
	Attr    *keibidrop.Attr // File attributes from Stat_t.
	// BaseMtimeNs is the newest peer version the sender accepted when the edit
	// session started. 0 means unknown; the receiver then keeps no conflict copy.
	BaseMtimeNs int64
}

FileEvent represents a filesystem change

type FileStreamProvider

type FileStreamProvider interface {
	OpenRemoteFile(ctx context.Context, inode uint64, path string) (RemoteFileStream, error)
	// StreamFile starts a push-based download. The server sends all chunks
	// from startOffset to EOF without per-chunk round-trips.
	StreamFile(ctx context.Context, path string, startOffset uint64) (StreamFileReceiver, error)
}

FileStreamProvider is a factory for RemoteFileStream and StreamFile.

type RemoteFileStream

type RemoteFileStream interface {
	// ReadAt sends offset and size and receives exactly those bytes.
	ReadAt(ctx context.Context, offset int64, size int64) ([]byte, error)
	Close() error
}

type StreamFileReceiver

type StreamFileReceiver interface {
	// Recv returns the next chunk. It returns io.EOF when the stream ends.
	Recv() (data []byte, offset uint64, totalSize uint64, err error)
}

StreamFileReceiver receives pushed chunks from the server.

Jump to

Keyboard shortcuts

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