db

package
v0.0.0-...-129a086 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package db provides a set type to track local/remote files with newness checks. We must do a certain amount of normalization in here. We will get fed paths with either native or wire-format separators and encodings depending on who calls us. We transform paths to wire-format (NFC and slashes) on the way to the database, and transform to native format (varying separator and encoding) on the way back out.

Index

Constants

View Source
const (
	// KeyTypeDevice <int32 folder ID> <int32 device ID> <file name> = FileInfo
	KeyTypeDevice byte = 0

	// KeyTypeGlobal <int32 folder ID> <file name> = VersionList
	KeyTypeGlobal byte = 1

	// KeyTypeBlock <int32 folder ID> <32 bytes hash> <§file name> = int32 (block index)
	KeyTypeBlock byte = 2

	// KeyTypeDeviceStatistic <device ID as string> <some string> = some value
	KeyTypeDeviceStatistic byte = 3

	// KeyTypeFolderStatistic <folder ID as string> <some string> = some value
	KeyTypeFolderStatistic byte = 4

	// KeyTypeVirtualMtime <int32 folder ID> <file name> = mtimeMapping
	KeyTypeVirtualMtime byte = 5

	// KeyTypeFolderIdx <int32 id> = string value
	KeyTypeFolderIdx byte = 6

	// KeyTypeDeviceIdx <int32 id> = string value
	KeyTypeDeviceIdx byte = 7

	// KeyTypeIndexID <int32 device ID> <int32 folder ID> = protocol.IndexID
	KeyTypeIndexID byte = 8

	// KeyTypeFolderMeta <int32 folder ID> = CountsSet
	KeyTypeFolderMeta byte = 9

	// KeyTypeMiscData <some string> = some value
	KeyTypeMiscData byte = 10

	// KeyTypeSequence <int32 folder ID> <int64 sequence number> = KeyTypeDevice key
	KeyTypeSequence byte = 11

	// KeyTypeNeed <int32 folder ID> <file name> = <nothing>
	KeyTypeNeed byte = 12

	// KeyTypeBlockList <block list hash> = BlockList
	KeyTypeBlockList byte = 13

	// KeyTypeBlockListMap <int32 folder ID> <block list hash> <file name> = <nothing>
	KeyTypeBlockListMap byte = 14

	// KeyTypeVersion <version hash> = Vector
	KeyTypeVersion byte = 15

	// KeyTypePendingFolder <int32 device ID> <folder ID as string> = ObservedFolder
	KeyTypePendingFolder byte = 16

	// KeyTypePendingDevice <device ID in wire format> = ObservedDevice
	KeyTypePendingDevice byte = 17
)
View Source
const (
	MaxBatchSizeBytes = 250 * 1024 // Aim for making index messages no larger than 250 KiB (uncompressed)
	MaxBatchSizeFiles = 1000       // Either way, don't include more files than this
)

How many files to send in each Index/IndexUpdate message.

Variables

View Source
var (
	ErrInvalidLengthStructs        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowStructs          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupStructs = fmt.Errorf("proto: unexpected end of group")
)

Functions

func DropDeltaIndexIDs

func DropDeltaIndexIDs(db *Lowlevel)

DropDeltaIndexIDs removes all delta index IDs from the database. This will cause a full index transmission on the next connection. Must be called before using FileSets, i.e. before NewFileSet is called for the first time.

func DropFolder

func DropFolder(db *Lowlevel, folder string)

DropFolder clears out all information related to the given folder from the database.

func Need

func Need(global FileVersion, haveLocal bool, localVersion protocol.Vector) bool

func UpdateSchema

func UpdateSchema(db *Lowlevel) error

UpdateSchema updates a possibly outdated database to the current schema and also does repairs where necessary.

Types

type BlockFinder

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

func NewBlockFinder

func NewBlockFinder(db *Lowlevel) *BlockFinder

func (*BlockFinder) Iterate

func (f *BlockFinder) Iterate(folders []string, hash []byte, iterFn func(string, string, int32) bool) bool

Iterate takes an iterator function which iterates over all matching blocks for the given hash. The iterator function has to return either true (if they are happy with the block) or false to continue iterating for whatever reason. The iterator finally returns the result, whether or not a satisfying block was eventually found.

func (*BlockFinder) String

func (f *BlockFinder) String() string

type BlockList

type BlockList struct {
	Blocks []protocol.BlockInfo `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks" xml:"block"`
}

BlockList is the structure used to store block lists

func (*BlockList) Descriptor

func (*BlockList) Descriptor() ([]byte, []int)

func (*BlockList) Marshal

func (m *BlockList) Marshal() (dAtA []byte, err error)

func (*BlockList) MarshalTo

func (m *BlockList) MarshalTo(dAtA []byte) (int, error)

func (*BlockList) MarshalToSizedBuffer

func (m *BlockList) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BlockList) ProtoMessage

func (*BlockList) ProtoMessage()

func (*BlockList) ProtoSize

func (m *BlockList) ProtoSize() (n int)

func (*BlockList) Reset

func (m *BlockList) Reset()

func (*BlockList) String

func (m *BlockList) String() string

func (*BlockList) Unmarshal

func (m *BlockList) Unmarshal(dAtA []byte) error

func (*BlockList) XXX_DiscardUnknown

func (m *BlockList) XXX_DiscardUnknown()

func (*BlockList) XXX_Marshal

func (m *BlockList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BlockList) XXX_Merge

func (m *BlockList) XXX_Merge(src proto.Message)

func (*BlockList) XXX_Size

func (m *BlockList) XXX_Size() int

func (*BlockList) XXX_Unmarshal

func (m *BlockList) XXX_Unmarshal(b []byte) error

type Counts

type Counts struct {
	Files       int    `protobuf:"varint,1,opt,name=files,proto3,casttype=int" json:"files" xml:"files"`
	Directories int    `protobuf:"varint,2,opt,name=directories,proto3,casttype=int" json:"directories" xml:"directories"`
	Symlinks    int    `protobuf:"varint,3,opt,name=symlinks,proto3,casttype=int" json:"symlinks" xml:"symlinks"`
	Deleted     int    `protobuf:"varint,4,opt,name=deleted,proto3,casttype=int" json:"deleted" xml:"deleted"`
	Bytes       int64  `protobuf:"varint,5,opt,name=bytes,proto3" json:"bytes" xml:"bytes"`
	Sequence    int64  `protobuf:"varint,6,opt,name=sequence,proto3" json:"sequence" xml:"sequence"`
	DeviceID    []byte `protobuf:"bytes,17,opt,name=device_id,json=deviceId,proto3" json:"deviceId" xml:"deviceId"`
	LocalFlags  uint32 `protobuf:"varint,18,opt,name=local_flags,json=localFlags,proto3" json:"localFlags" xml:"localFlags"`
}

For each folder and device we keep one of these to track the current counts and sequence. We also keep one for the global state of the folder.

func (Counts) Add

func (c Counts) Add(other Counts) Counts

func (*Counts) Descriptor

func (*Counts) Descriptor() ([]byte, []int)

func (Counts) Equal

func (c Counts) Equal(o Counts) bool

Equal compares the numbers only, not sequence/dev/flags.

func (*Counts) Marshal

func (m *Counts) Marshal() (dAtA []byte, err error)

func (*Counts) MarshalTo

func (m *Counts) MarshalTo(dAtA []byte) (int, error)

func (*Counts) MarshalToSizedBuffer

func (m *Counts) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Counts) ProtoMessage

func (*Counts) ProtoMessage()

func (*Counts) ProtoSize

func (m *Counts) ProtoSize() (n int)

func (*Counts) Reset

func (m *Counts) Reset()

func (Counts) String

func (c Counts) String() string

func (Counts) TotalItems

func (c Counts) TotalItems() int

func (*Counts) Unmarshal

func (m *Counts) Unmarshal(dAtA []byte) error

func (*Counts) XXX_DiscardUnknown

func (m *Counts) XXX_DiscardUnknown()

func (*Counts) XXX_Marshal

func (m *Counts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Counts) XXX_Merge

func (m *Counts) XXX_Merge(src proto.Message)

func (*Counts) XXX_Size

func (m *Counts) XXX_Size() int

func (*Counts) XXX_Unmarshal

func (m *Counts) XXX_Unmarshal(b []byte) error

type CountsSet

type CountsSet struct {
	Counts  []Counts `protobuf:"bytes,1,rep,name=counts,proto3" json:"counts" xml:"count"`
	Created int64    `protobuf:"varint,2,opt,name=created,proto3" json:"created" xml:"created"`
}

func (*CountsSet) Descriptor

func (*CountsSet) Descriptor() ([]byte, []int)

func (*CountsSet) Marshal

func (m *CountsSet) Marshal() (dAtA []byte, err error)

func (*CountsSet) MarshalTo

func (m *CountsSet) MarshalTo(dAtA []byte) (int, error)

func (*CountsSet) MarshalToSizedBuffer

func (m *CountsSet) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CountsSet) ProtoMessage

func (*CountsSet) ProtoMessage()

func (*CountsSet) ProtoSize

func (m *CountsSet) ProtoSize() (n int)

func (*CountsSet) Reset

func (m *CountsSet) Reset()

func (*CountsSet) String

func (m *CountsSet) String() string

func (*CountsSet) Unmarshal

func (m *CountsSet) Unmarshal(dAtA []byte) error

func (*CountsSet) XXX_DiscardUnknown

func (m *CountsSet) XXX_DiscardUnknown()

func (*CountsSet) XXX_Marshal

func (m *CountsSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CountsSet) XXX_Merge

func (m *CountsSet) XXX_Merge(src proto.Message)

func (*CountsSet) XXX_Size

func (m *CountsSet) XXX_Size() int

func (*CountsSet) XXX_Unmarshal

func (m *CountsSet) XXX_Unmarshal(b []byte) error

type FileInfoBatch

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

FileInfoBatch is a utility to do file operations on the database in suitably sized batches.

func NewFileInfoBatch

func NewFileInfoBatch(fn func([]protocol.FileInfo) error) *FileInfoBatch

func (*FileInfoBatch) Append

func (b *FileInfoBatch) Append(f protocol.FileInfo)

func (*FileInfoBatch) Flush

func (b *FileInfoBatch) Flush() error

func (*FileInfoBatch) FlushIfFull

func (b *FileInfoBatch) FlushIfFull() error

func (*FileInfoBatch) Full

func (b *FileInfoBatch) Full() bool

func (*FileInfoBatch) Reset

func (b *FileInfoBatch) Reset()

func (*FileInfoBatch) SetFlushFunc

func (b *FileInfoBatch) SetFlushFunc(fn func([]protocol.FileInfo) error)

func (*FileInfoBatch) Size

func (b *FileInfoBatch) Size() int

type FileInfoTruncated

type FileInfoTruncated struct {
	Name       string                                                    `protobuf:"bytes,1,opt,name=name,proto3" json:"name" xml:"name"`
	Size       int64                                                     `protobuf:"varint,3,opt,name=size,proto3" json:"size" xml:"size"`
	ModifiedS  int64                                                     `protobuf:"varint,5,opt,name=modified_s,json=modifiedS,proto3" json:"modifiedS" xml:"modifiedS"`
	ModifiedBy github_com_zebfross_syncthing_mobile_lib_protocol.ShortID `` /* 168-byte string literal not displayed */
	Version    protocol.Vector                                           `protobuf:"bytes,9,opt,name=version,proto3" json:"version" xml:"version"`
	Sequence   int64                                                     `protobuf:"varint,10,opt,name=sequence,proto3" json:"sequence" xml:"sequence"`
	// repeated BlockInfo Blocks         = 16
	SymlinkTarget string                `protobuf:"bytes,17,opt,name=symlink_target,json=symlinkTarget,proto3" json:"symlinkTarget" xml:"symlinkTarget"`
	BlocksHash    []byte                `protobuf:"bytes,18,opt,name=blocks_hash,json=blocksHash,proto3" json:"blocksHash" xml:"blocksHash"`
	Encrypted     []byte                `protobuf:"bytes,19,opt,name=encrypted,proto3" json:"encrypted" xml:"encrypted"`
	Type          protocol.FileInfoType `protobuf:"varint,2,opt,name=type,proto3,enum=protocol.FileInfoType" json:"type" xml:"type"`
	Permissions   uint32                `protobuf:"varint,4,opt,name=permissions,proto3" json:"permissions" xml:"permissions"`
	ModifiedNs    int                   `protobuf:"varint,11,opt,name=modified_ns,json=modifiedNs,proto3,casttype=int" json:"modifiedNs" xml:"modifiedNs"`
	RawBlockSize  int                   `protobuf:"varint,13,opt,name=block_size,json=blockSize,proto3,casttype=int" json:"blockSize" xml:"blockSize"`
	Platform      protocol.PlatformData `protobuf:"bytes,14,opt,name=platform,proto3" json:"platform" xml:"platform"`
	// see bep.proto
	LocalFlags    uint32 `protobuf:"varint,1000,opt,name=local_flags,json=localFlags,proto3" json:"localFlags" xml:"localFlags"`
	VersionHash   []byte `protobuf:"bytes,1001,opt,name=version_hash,json=versionHash,proto3" json:"versionHash" xml:"versionHash"`
	Deleted       bool   `protobuf:"varint,6,opt,name=deleted,proto3" json:"deleted" xml:"deleted"`
	RawInvalid    bool   `protobuf:"varint,7,opt,name=invalid,proto3" json:"invalid" xml:"invalid"`
	NoPermissions bool   `protobuf:"varint,8,opt,name=no_permissions,json=noPermissions,proto3" json:"noPermissions" xml:"noPermissions"`
}

Must be the same as FileInfo but without the blocks field

func (FileInfoTruncated) BlockSize

func (f FileInfoTruncated) BlockSize() int

func (FileInfoTruncated) ConvertDeletedToFileInfo

func (f FileInfoTruncated) ConvertDeletedToFileInfo() protocol.FileInfo

ConvertDeletedToFileInfo converts a deleted truncated file info to a regular file info

func (FileInfoTruncated) ConvertToDeletedFileInfo

func (f FileInfoTruncated) ConvertToDeletedFileInfo(by protocol.ShortID) protocol.FileInfo

func (FileInfoTruncated) ConvertToIgnoredFileInfo

func (f FileInfoTruncated) ConvertToIgnoredFileInfo() protocol.FileInfo

func (*FileInfoTruncated) Descriptor

func (*FileInfoTruncated) Descriptor() ([]byte, []int)

func (FileInfoTruncated) FileLocalFlags

func (f FileInfoTruncated) FileLocalFlags() uint32

func (FileInfoTruncated) FileModifiedBy

func (f FileInfoTruncated) FileModifiedBy() protocol.ShortID

func (FileInfoTruncated) FileName

func (f FileInfoTruncated) FileName() string

func (FileInfoTruncated) FilePermissions

func (f FileInfoTruncated) FilePermissions() uint32

func (FileInfoTruncated) FileSize

func (f FileInfoTruncated) FileSize() int64

func (FileInfoTruncated) FileType

func (FileInfoTruncated) FileVersion

func (f FileInfoTruncated) FileVersion() protocol.Vector

func (FileInfoTruncated) HasPermissionBits

func (f FileInfoTruncated) HasPermissionBits() bool

func (FileInfoTruncated) IsDeleted

func (f FileInfoTruncated) IsDeleted() bool

func (FileInfoTruncated) IsDirectory

func (f FileInfoTruncated) IsDirectory() bool

func (FileInfoTruncated) IsIgnored

func (f FileInfoTruncated) IsIgnored() bool

func (FileInfoTruncated) IsInvalid

func (f FileInfoTruncated) IsInvalid() bool

func (FileInfoTruncated) IsReceiveOnlyChanged

func (f FileInfoTruncated) IsReceiveOnlyChanged() bool
func (f FileInfoTruncated) IsSymlink() bool

func (FileInfoTruncated) IsUnsupported

func (f FileInfoTruncated) IsUnsupported() bool

func (*FileInfoTruncated) Marshal

func (m *FileInfoTruncated) Marshal() (dAtA []byte, err error)

func (*FileInfoTruncated) MarshalTo

func (m *FileInfoTruncated) MarshalTo(dAtA []byte) (int, error)

func (*FileInfoTruncated) MarshalToSizedBuffer

func (m *FileInfoTruncated) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (FileInfoTruncated) ModTime

func (f FileInfoTruncated) ModTime() time.Time

func (FileInfoTruncated) MustRescan

func (f FileInfoTruncated) MustRescan() bool

func (*FileInfoTruncated) ProtoMessage

func (*FileInfoTruncated) ProtoMessage()

func (*FileInfoTruncated) ProtoSize

func (m *FileInfoTruncated) ProtoSize() (n int)

func (*FileInfoTruncated) Reset

func (m *FileInfoTruncated) Reset()

func (FileInfoTruncated) SequenceNo

func (f FileInfoTruncated) SequenceNo() int64

func (FileInfoTruncated) ShouldConflict

func (f FileInfoTruncated) ShouldConflict() bool

func (FileInfoTruncated) String

func (f FileInfoTruncated) String() string

func (*FileInfoTruncated) Unmarshal

func (m *FileInfoTruncated) Unmarshal(dAtA []byte) error

func (*FileInfoTruncated) XXX_DiscardUnknown

func (m *FileInfoTruncated) XXX_DiscardUnknown()

func (*FileInfoTruncated) XXX_Marshal

func (m *FileInfoTruncated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FileInfoTruncated) XXX_Merge

func (m *FileInfoTruncated) XXX_Merge(src proto.Message)

func (*FileInfoTruncated) XXX_Size

func (m *FileInfoTruncated) XXX_Size() int

func (*FileInfoTruncated) XXX_Unmarshal

func (m *FileInfoTruncated) XXX_Unmarshal(b []byte) error

type FileSet

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

func NewFileSet

func NewFileSet(folder string, db *Lowlevel) (*FileSet, error)

func (*FileSet) Drop

func (s *FileSet) Drop(device protocol.DeviceID)

func (*FileSet) IndexID

func (s *FileSet) IndexID(device protocol.DeviceID) protocol.IndexID

func (*FileSet) ListDevices

func (s *FileSet) ListDevices() []protocol.DeviceID

func (*FileSet) MtimeOption

func (s *FileSet) MtimeOption() fs.Option

func (*FileSet) RemoveLocalItems

func (s *FileSet) RemoveLocalItems(items []string)

func (*FileSet) RepairSequence

func (s *FileSet) RepairSequence() (int, error)

func (*FileSet) Sequence

func (s *FileSet) Sequence(device protocol.DeviceID) int64

func (*FileSet) SetIndexID

func (s *FileSet) SetIndexID(device protocol.DeviceID, id protocol.IndexID)

func (*FileSet) Snapshot

func (s *FileSet) Snapshot() (*Snapshot, error)

func (*FileSet) Update

func (s *FileSet) Update(device protocol.DeviceID, fs []protocol.FileInfo)

type FileVersion

type FileVersion struct {
	Version        protocol.Vector `protobuf:"bytes,1,opt,name=version,proto3" json:"version" xml:"version"`
	Deleted        bool            `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted" xml:"deleted"`
	Devices        [][]byte        `protobuf:"bytes,3,rep,name=devices,proto3" json:"devices" xml:"device"`
	InvalidDevices [][]byte        `protobuf:"bytes,4,rep,name=invalid_devices,json=invalidDevices,proto3" json:"invalidDevices" xml:"invalidDevice"`
}

func (*FileVersion) Descriptor

func (*FileVersion) Descriptor() ([]byte, []int)

func (FileVersion) FirstDevice

func (fv FileVersion) FirstDevice() ([]byte, bool)

func (FileVersion) IsInvalid

func (fv FileVersion) IsInvalid() bool

func (*FileVersion) Marshal

func (m *FileVersion) Marshal() (dAtA []byte, err error)

func (*FileVersion) MarshalTo

func (m *FileVersion) MarshalTo(dAtA []byte) (int, error)

func (*FileVersion) MarshalToSizedBuffer

func (m *FileVersion) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*FileVersion) ProtoMessage

func (*FileVersion) ProtoMessage()

func (*FileVersion) ProtoSize

func (m *FileVersion) ProtoSize() (n int)

func (*FileVersion) Reset

func (m *FileVersion) Reset()

func (*FileVersion) String

func (m *FileVersion) String() string

func (*FileVersion) Unmarshal

func (m *FileVersion) Unmarshal(dAtA []byte) error

func (*FileVersion) XXX_DiscardUnknown

func (m *FileVersion) XXX_DiscardUnknown()

func (*FileVersion) XXX_Marshal

func (m *FileVersion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FileVersion) XXX_Merge

func (m *FileVersion) XXX_Merge(src proto.Message)

func (*FileVersion) XXX_Size

func (m *FileVersion) XXX_Size() int

func (*FileVersion) XXX_Unmarshal

func (m *FileVersion) XXX_Unmarshal(b []byte) error

type FileVersionDeprecated

type FileVersionDeprecated struct {
	Version protocol.Vector `protobuf:"bytes,1,opt,name=version,proto3" json:"version" xml:"version"`
	Device  []byte          `protobuf:"bytes,2,opt,name=device,proto3" json:"device" xml:"device"`
	Invalid bool            `protobuf:"varint,3,opt,name=invalid,proto3" json:"invalid" xml:"invalid"`
	Deleted bool            `protobuf:"varint,4,opt,name=deleted,proto3" json:"deleted" xml:"deleted"`
}

func (*FileVersionDeprecated) Descriptor

func (*FileVersionDeprecated) Descriptor() ([]byte, []int)

func (*FileVersionDeprecated) Marshal

func (m *FileVersionDeprecated) Marshal() (dAtA []byte, err error)

func (*FileVersionDeprecated) MarshalTo

func (m *FileVersionDeprecated) MarshalTo(dAtA []byte) (int, error)

func (*FileVersionDeprecated) MarshalToSizedBuffer

func (m *FileVersionDeprecated) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*FileVersionDeprecated) ProtoMessage

func (*FileVersionDeprecated) ProtoMessage()

func (*FileVersionDeprecated) ProtoSize

func (m *FileVersionDeprecated) ProtoSize() (n int)

func (*FileVersionDeprecated) Reset

func (m *FileVersionDeprecated) Reset()

func (*FileVersionDeprecated) String

func (m *FileVersionDeprecated) String() string

func (*FileVersionDeprecated) Unmarshal

func (m *FileVersionDeprecated) Unmarshal(dAtA []byte) error

func (*FileVersionDeprecated) XXX_DiscardUnknown

func (m *FileVersionDeprecated) XXX_DiscardUnknown()

func (*FileVersionDeprecated) XXX_Marshal

func (m *FileVersionDeprecated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FileVersionDeprecated) XXX_Merge

func (m *FileVersionDeprecated) XXX_Merge(src proto.Message)

func (*FileVersionDeprecated) XXX_Size

func (m *FileVersionDeprecated) XXX_Size() int

func (*FileVersionDeprecated) XXX_Unmarshal

func (m *FileVersionDeprecated) XXX_Unmarshal(b []byte) error

type IndirectionHashesOnly

type IndirectionHashesOnly struct {
	BlocksHash  []byte `protobuf:"bytes,18,opt,name=blocks_hash,json=blocksHash,proto3" json:"blocksHash" xml:"blocksHash"`
	VersionHash []byte `protobuf:"bytes,1001,opt,name=version_hash,json=versionHash,proto3" json:"versionHash" xml:"versionHash"`
}

IndirectionHashesOnly is used to only unmarshal the indirection hashes from a FileInfo

func (*IndirectionHashesOnly) Descriptor

func (*IndirectionHashesOnly) Descriptor() ([]byte, []int)

func (*IndirectionHashesOnly) Marshal

func (m *IndirectionHashesOnly) Marshal() (dAtA []byte, err error)

func (*IndirectionHashesOnly) MarshalTo

func (m *IndirectionHashesOnly) MarshalTo(dAtA []byte) (int, error)

func (*IndirectionHashesOnly) MarshalToSizedBuffer

func (m *IndirectionHashesOnly) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*IndirectionHashesOnly) ProtoMessage

func (*IndirectionHashesOnly) ProtoMessage()

func (*IndirectionHashesOnly) ProtoSize

func (m *IndirectionHashesOnly) ProtoSize() (n int)

func (*IndirectionHashesOnly) Reset

func (m *IndirectionHashesOnly) Reset()

func (*IndirectionHashesOnly) String

func (m *IndirectionHashesOnly) String() string

func (*IndirectionHashesOnly) Unmarshal

func (m *IndirectionHashesOnly) Unmarshal(dAtA []byte) error

func (*IndirectionHashesOnly) XXX_DiscardUnknown

func (m *IndirectionHashesOnly) XXX_DiscardUnknown()

func (*IndirectionHashesOnly) XXX_Marshal

func (m *IndirectionHashesOnly) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*IndirectionHashesOnly) XXX_Merge

func (m *IndirectionHashesOnly) XXX_Merge(src proto.Message)

func (*IndirectionHashesOnly) XXX_Size

func (m *IndirectionHashesOnly) XXX_Size() int

func (*IndirectionHashesOnly) XXX_Unmarshal

func (m *IndirectionHashesOnly) XXX_Unmarshal(b []byte) error

type Iterator

type Iterator func(f protocol.FileIntf) bool

The Iterator is called with either a protocol.FileInfo or a FileInfoTruncated (depending on the method) and returns true to continue iteration, false to stop.

type Lowlevel

type Lowlevel struct {
	*suture.Supervisor
	backend.Backend
	// contains filtered or unexported fields
}

Lowlevel is the lowest level database interface. It has a very simple purpose: hold the actual backend database, and the in-memory state that belong to that database. In the same way that a single on disk database can only be opened once, there should be only one Lowlevel for any given backend.

func NewLowlevel

func NewLowlevel(backend backend.Backend, evLogger events.Logger, opts ...Option) (*Lowlevel, error)

func (*Lowlevel) AddOrUpdatePendingDevice

func (db *Lowlevel) AddOrUpdatePendingDevice(device protocol.DeviceID, name, address string) error

func (*Lowlevel) AddOrUpdatePendingFolder

func (db *Lowlevel) AddOrUpdatePendingFolder(id string, of ObservedFolder, device protocol.DeviceID) error

func (*Lowlevel) ListFolders

func (db *Lowlevel) ListFolders() []string

ListFolders returns the list of folders currently in the database

func (*Lowlevel) PendingDevices

func (db *Lowlevel) PendingDevices() (map[protocol.DeviceID]ObservedDevice, error)

PendingDevices enumerates all entries. Invalid ones are dropped from the database after a warning log message, as a side-effect.

func (*Lowlevel) PendingFolders

func (db *Lowlevel) PendingFolders() (map[string]PendingFolder, error)

func (*Lowlevel) PendingFoldersForDevice

func (db *Lowlevel) PendingFoldersForDevice(device protocol.DeviceID) (map[string]PendingFolder, error)

PendingFoldersForDevice enumerates only entries matching the given device ID, unless it is EmptyDeviceID. Invalid ones are dropped from the database after a info log message, as a side-effect.

func (*Lowlevel) RemovePendingDevice

func (db *Lowlevel) RemovePendingDevice(device protocol.DeviceID) error

func (*Lowlevel) RemovePendingFolder

func (db *Lowlevel) RemovePendingFolder(id string) error

RemovePendingFolder removes all entries matching a specific folder ID.

func (*Lowlevel) RemovePendingFolderForDevice

func (db *Lowlevel) RemovePendingFolderForDevice(id string, device protocol.DeviceID) error

RemovePendingFolderForDevice removes entries for specific folder / device combinations.

type NamespacedKV

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

NamespacedKV is a simple key-value store using a specific namespace within a leveldb.

func NewDeviceStatisticsNamespace

func NewDeviceStatisticsNamespace(db backend.Backend, device string) *NamespacedKV

NewDeviceStatisticsNamespace creates a KV namespace for device statistics for the given device.

func NewFolderStatisticsNamespace

func NewFolderStatisticsNamespace(db backend.Backend, folder string) *NamespacedKV

NewFolderStatisticsNamespace creates a KV namespace for folder statistics for the given folder.

func NewMiscDataNamespace

func NewMiscDataNamespace(db backend.Backend) *NamespacedKV

NewMiscDateNamespace creates a KV namespace for miscellaneous metadata.

func NewNamespacedKV

func NewNamespacedKV(db backend.Backend, prefix string) *NamespacedKV

NewNamespacedKV returns a new NamespacedKV that lives in the namespace specified by the prefix.

func (NamespacedKV) Bool

func (n NamespacedKV) Bool(key string) (bool, bool, error)

Bool returns the stored value as a boolean and a boolean that is false if no value was stored at the key.

func (NamespacedKV) Bytes

func (n NamespacedKV) Bytes(key string) ([]byte, bool, error)

Bytes returns the stored value as a raw byte slice and a boolean that is false if no value was stored at the key.

func (NamespacedKV) Delete

func (n NamespacedKV) Delete(key string) error

Delete deletes the specified key. It is allowed to delete a nonexistent key.

func (*NamespacedKV) Int64

func (n *NamespacedKV) Int64(key string) (int64, bool, error)

Int64 returns the stored value interpreted as an int64 and a boolean that is false if no value was stored at the key.

func (*NamespacedKV) PutBool

func (n *NamespacedKV) PutBool(key string, val bool) error

PutBool stores a new boolean. Any existing value (even if of another type) is overwritten.

func (*NamespacedKV) PutBytes

func (n *NamespacedKV) PutBytes(key string, val []byte) error

PutBytes stores a new byte slice. Any existing value (even if of another type) is overwritten.

func (*NamespacedKV) PutInt64

func (n *NamespacedKV) PutInt64(key string, val int64) error

PutInt64 stores a new int64. Any existing value (even if of another type) is overwritten.

func (*NamespacedKV) PutString

func (n *NamespacedKV) PutString(key, val string) error

PutString stores a new string. Any existing value (even if of another type) is overwritten.

func (*NamespacedKV) PutTime

func (n *NamespacedKV) PutTime(key string, val time.Time) error

PutTime stores a new time.Time. Any existing value (even if of another type) is overwritten.

func (NamespacedKV) String

func (n NamespacedKV) String(key string) (string, bool, error)

String returns the stored value interpreted as a string and a boolean that is false if no value was stored at the key.

func (NamespacedKV) Time

func (n NamespacedKV) Time(key string) (time.Time, bool, error)

Time returns the stored value interpreted as a time.Time and a boolean that is false if no value was stored at the key.

type ObservedDevice

type ObservedDevice struct {
	Time    time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time" xml:"time"`
	Name    string    `protobuf:"bytes,2,opt,name=name,proto3" json:"name" xml:"name"`
	Address string    `protobuf:"bytes,3,opt,name=address,proto3" json:"address" xml:"address"`
}

func (*ObservedDevice) Descriptor

func (*ObservedDevice) Descriptor() ([]byte, []int)

func (*ObservedDevice) Marshal

func (m *ObservedDevice) Marshal() (dAtA []byte, err error)

func (*ObservedDevice) MarshalTo

func (m *ObservedDevice) MarshalTo(dAtA []byte) (int, error)

func (*ObservedDevice) MarshalToSizedBuffer

func (m *ObservedDevice) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ObservedDevice) ProtoMessage

func (*ObservedDevice) ProtoMessage()

func (*ObservedDevice) ProtoSize

func (m *ObservedDevice) ProtoSize() (n int)

func (*ObservedDevice) Reset

func (m *ObservedDevice) Reset()

func (*ObservedDevice) String

func (m *ObservedDevice) String() string

func (*ObservedDevice) Unmarshal

func (m *ObservedDevice) Unmarshal(dAtA []byte) error

func (*ObservedDevice) XXX_DiscardUnknown

func (m *ObservedDevice) XXX_DiscardUnknown()

func (*ObservedDevice) XXX_Marshal

func (m *ObservedDevice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ObservedDevice) XXX_Merge

func (m *ObservedDevice) XXX_Merge(src proto.Message)

func (*ObservedDevice) XXX_Size

func (m *ObservedDevice) XXX_Size() int

func (*ObservedDevice) XXX_Unmarshal

func (m *ObservedDevice) XXX_Unmarshal(b []byte) error

type ObservedFolder

type ObservedFolder struct {
	Time             time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time" xml:"time"`
	Label            string    `protobuf:"bytes,2,opt,name=label,proto3" json:"label" xml:"label"`
	ReceiveEncrypted bool      `protobuf:"varint,3,opt,name=receive_encrypted,json=receiveEncrypted,proto3" json:"receiveEncrypted" xml:"receiveEncrypted"`
	RemoteEncrypted  bool      `protobuf:"varint,4,opt,name=remote_encrypted,json=remoteEncrypted,proto3" json:"remoteEncrypted" xml:"remoteEncrypted"`
}

func (*ObservedFolder) Descriptor

func (*ObservedFolder) Descriptor() ([]byte, []int)

func (*ObservedFolder) Marshal

func (m *ObservedFolder) Marshal() (dAtA []byte, err error)

func (*ObservedFolder) MarshalTo

func (m *ObservedFolder) MarshalTo(dAtA []byte) (int, error)

func (*ObservedFolder) MarshalToSizedBuffer

func (m *ObservedFolder) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ObservedFolder) ProtoMessage

func (*ObservedFolder) ProtoMessage()

func (*ObservedFolder) ProtoSize

func (m *ObservedFolder) ProtoSize() (n int)

func (*ObservedFolder) Reset

func (m *ObservedFolder) Reset()

func (*ObservedFolder) String

func (m *ObservedFolder) String() string

func (*ObservedFolder) Unmarshal

func (m *ObservedFolder) Unmarshal(dAtA []byte) error

func (*ObservedFolder) XXX_DiscardUnknown

func (m *ObservedFolder) XXX_DiscardUnknown()

func (*ObservedFolder) XXX_Marshal

func (m *ObservedFolder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ObservedFolder) XXX_Merge

func (m *ObservedFolder) XXX_Merge(src proto.Message)

func (*ObservedFolder) XXX_Size

func (m *ObservedFolder) XXX_Size() int

func (*ObservedFolder) XXX_Unmarshal

func (m *ObservedFolder) XXX_Unmarshal(b []byte) error

type Option

type Option func(*Lowlevel)

func WithIndirectGCInterval

func WithIndirectGCInterval(dur time.Duration) Option

WithIndirectGCInterval sets the time interval in between GC runs.

func WithRecheckInterval

func WithRecheckInterval(dur time.Duration) Option

WithRecheckInterval sets the time interval in between metadata recalculations and consistency checks.

type PendingFolder

type PendingFolder struct {
	OfferedBy map[protocol.DeviceID]ObservedFolder `json:"offeredBy"`
}

Consolidated information about a pending folder

type Snapshot

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

func (*Snapshot) Availability

func (s *Snapshot) Availability(file string) []protocol.DeviceID

func (*Snapshot) DebugGlobalVersions

func (s *Snapshot) DebugGlobalVersions(file string) VersionList

func (*Snapshot) Get

func (s *Snapshot) Get(device protocol.DeviceID, file string) (protocol.FileInfo, bool)

func (*Snapshot) GetGlobal

func (s *Snapshot) GetGlobal(file string) (protocol.FileInfo, bool)

func (*Snapshot) GetGlobalTruncated

func (s *Snapshot) GetGlobalTruncated(file string) (FileInfoTruncated, bool)

func (*Snapshot) GlobalSize

func (s *Snapshot) GlobalSize() Counts

func (*Snapshot) LocalSize

func (s *Snapshot) LocalSize() Counts

func (*Snapshot) NeedSize

func (s *Snapshot) NeedSize(device protocol.DeviceID) Counts

func (*Snapshot) ReceiveOnlyChangedSize

func (s *Snapshot) ReceiveOnlyChangedSize() Counts

func (*Snapshot) Release

func (s *Snapshot) Release()

func (*Snapshot) RemoteSequence

func (s *Snapshot) RemoteSequence() int64

RemoteSequence returns the change version for the given folder, as sent by remote peers. This is guaranteed to increment if the contents of the remote or global folder has changed.

func (*Snapshot) Sequence

func (s *Snapshot) Sequence(device protocol.DeviceID) int64

func (*Snapshot) WithBlocksHash

func (s *Snapshot) WithBlocksHash(hash []byte, fn Iterator)

func (*Snapshot) WithGlobal

func (s *Snapshot) WithGlobal(fn Iterator)

func (*Snapshot) WithGlobalTruncated

func (s *Snapshot) WithGlobalTruncated(fn Iterator)

func (*Snapshot) WithHave

func (s *Snapshot) WithHave(device protocol.DeviceID, fn Iterator)

func (*Snapshot) WithHaveSequence

func (s *Snapshot) WithHaveSequence(startSeq int64, fn Iterator)

func (*Snapshot) WithHaveTruncated

func (s *Snapshot) WithHaveTruncated(device protocol.DeviceID, fn Iterator)

func (*Snapshot) WithNeed

func (s *Snapshot) WithNeed(device protocol.DeviceID, fn Iterator)

func (*Snapshot) WithNeedTruncated

func (s *Snapshot) WithNeedTruncated(device protocol.DeviceID, fn Iterator)

func (*Snapshot) WithPrefixedGlobalTruncated

func (s *Snapshot) WithPrefixedGlobalTruncated(prefix string, fn Iterator)

Except for an item with a path equal to prefix, only children of prefix are iterated. E.g. for prefix "dir", "dir/file" is iterated, but "dir.file" is not.

func (*Snapshot) WithPrefixedHaveTruncated

func (s *Snapshot) WithPrefixedHaveTruncated(device protocol.DeviceID, prefix string, fn Iterator)

Except for an item with a path equal to prefix, only children of prefix are iterated. E.g. for prefix "dir", "dir/file" is iterated, but "dir.file" is not.

type VersionList

type VersionList struct {
	RawVersions []FileVersion `protobuf:"bytes,1,rep,name=versions,proto3" json:"versions" xml:"version"`
}

func (*VersionList) Descriptor

func (*VersionList) Descriptor() ([]byte, []int)

func (*VersionList) Empty

func (vl *VersionList) Empty() bool

func (*VersionList) Get

func (vl *VersionList) Get(device []byte) (FileVersion, bool)

Get returns a FileVersion that contains the given device and whether it has been found at all.

func (*VersionList) GetGlobal

func (vl *VersionList) GetGlobal() (FileVersion, bool)

GetGlobal returns the current global FileVersion. The returned FileVersion may be invalid, if all FileVersions are invalid. Returns false only if VersionList is empty.

func (*VersionList) Marshal

func (m *VersionList) Marshal() (dAtA []byte, err error)

func (*VersionList) MarshalTo

func (m *VersionList) MarshalTo(dAtA []byte) (int, error)

func (*VersionList) MarshalToSizedBuffer

func (m *VersionList) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*VersionList) ProtoMessage

func (*VersionList) ProtoMessage()

func (*VersionList) ProtoSize

func (m *VersionList) ProtoSize() (n int)

func (*VersionList) Reset

func (m *VersionList) Reset()

func (VersionList) String

func (vl VersionList) String() string

func (*VersionList) Unmarshal

func (m *VersionList) Unmarshal(dAtA []byte) error

func (*VersionList) XXX_DiscardUnknown

func (m *VersionList) XXX_DiscardUnknown()

func (*VersionList) XXX_Marshal

func (m *VersionList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*VersionList) XXX_Merge

func (m *VersionList) XXX_Merge(src proto.Message)

func (*VersionList) XXX_Size

func (m *VersionList) XXX_Size() int

func (*VersionList) XXX_Unmarshal

func (m *VersionList) XXX_Unmarshal(b []byte) error

type VersionListDeprecated

type VersionListDeprecated struct {
	Versions []FileVersionDeprecated `protobuf:"bytes,1,rep,name=versions,proto3" json:"versions" xml:"version"`
}

func (*VersionListDeprecated) Descriptor

func (*VersionListDeprecated) Descriptor() ([]byte, []int)

func (*VersionListDeprecated) Get

func (*VersionListDeprecated) Marshal

func (m *VersionListDeprecated) Marshal() (dAtA []byte, err error)

func (*VersionListDeprecated) MarshalTo

func (m *VersionListDeprecated) MarshalTo(dAtA []byte) (int, error)

func (*VersionListDeprecated) MarshalToSizedBuffer

func (m *VersionListDeprecated) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*VersionListDeprecated) ProtoMessage

func (*VersionListDeprecated) ProtoMessage()

func (*VersionListDeprecated) ProtoSize

func (m *VersionListDeprecated) ProtoSize() (n int)

func (*VersionListDeprecated) Reset

func (m *VersionListDeprecated) Reset()

func (*VersionListDeprecated) String

func (vl *VersionListDeprecated) String() string

func (*VersionListDeprecated) Unmarshal

func (m *VersionListDeprecated) Unmarshal(dAtA []byte) error

func (*VersionListDeprecated) XXX_DiscardUnknown

func (m *VersionListDeprecated) XXX_DiscardUnknown()

func (*VersionListDeprecated) XXX_Marshal

func (m *VersionListDeprecated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*VersionListDeprecated) XXX_Merge

func (m *VersionListDeprecated) XXX_Merge(src proto.Message)

func (*VersionListDeprecated) XXX_Size

func (m *VersionListDeprecated) XXX_Size() int

func (*VersionListDeprecated) XXX_Unmarshal

func (m *VersionListDeprecated) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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