db

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: MPL-2.0 Imports: 28 Imported by: 10

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> = dbMtime
	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
)

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 added in v0.14.52

func DropDeltaIndexIDs(db *Lowlevel)

DropDeltaIndexIDs removes all delta index IDs from the database. This will cause a full index transmission on the next connection.

func DropFolder

func DropFolder(db *Lowlevel, folder string)

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

func Need added in v1.10.0

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

func UpdateSchema added in v0.14.52

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 added in v1.4.0

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 added in v1.4.0

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

func (*BlockList) Marshal added in v1.4.0

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

func (*BlockList) MarshalTo added in v1.4.0

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

func (*BlockList) MarshalToSizedBuffer added in v1.4.0

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

func (*BlockList) ProtoMessage added in v1.4.0

func (*BlockList) ProtoMessage()

func (*BlockList) ProtoSize added in v1.4.0

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

func (*BlockList) Reset added in v1.4.0

func (m *BlockList) Reset()

func (*BlockList) String added in v1.4.0

func (m *BlockList) String() string

func (*BlockList) Unmarshal added in v1.4.0

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

func (*BlockList) XXX_DiscardUnknown added in v1.4.0

func (m *BlockList) XXX_DiscardUnknown()

func (*BlockList) XXX_Marshal added in v1.4.0

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

func (*BlockList) XXX_Merge added in v1.4.0

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

func (*BlockList) XXX_Size added in v1.4.0

func (m *BlockList) XXX_Size() int

func (*BlockList) XXX_Unmarshal added in v1.4.0

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

type Counts added in v0.14.10

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 added in v0.14.50

func (c Counts) Add(other Counts) Counts

func (*Counts) Descriptor added in v0.14.43

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

func (Counts) Equal added in v1.6.0

func (c Counts) Equal(o Counts) bool

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

func (*Counts) Marshal added in v0.14.43

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

func (*Counts) MarshalTo added in v0.14.43

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

func (*Counts) MarshalToSizedBuffer added in v1.3.0

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

func (*Counts) ProtoMessage added in v0.14.43

func (*Counts) ProtoMessage()

func (*Counts) ProtoSize added in v0.14.43

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

func (*Counts) Reset added in v0.14.43

func (m *Counts) Reset()

func (Counts) String added in v0.14.43

func (c Counts) String() string

func (Counts) TotalItems added in v1.0.0

func (c Counts) TotalItems() int

func (*Counts) Unmarshal added in v0.14.43

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

func (*Counts) XXX_DiscardUnknown added in v1.0.1

func (m *Counts) XXX_DiscardUnknown()

func (*Counts) XXX_Marshal added in v1.0.1

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

func (*Counts) XXX_Merge added in v1.0.1

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

func (*Counts) XXX_Size added in v1.0.1

func (m *Counts) XXX_Size() int

func (*Counts) XXX_Unmarshal added in v1.0.1

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

type CountsSet added in v0.14.43

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 added in v0.14.43

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

func (*CountsSet) Marshal added in v0.14.43

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

func (*CountsSet) MarshalTo added in v0.14.43

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

func (*CountsSet) MarshalToSizedBuffer added in v1.3.0

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

func (*CountsSet) ProtoMessage added in v0.14.43

func (*CountsSet) ProtoMessage()

func (*CountsSet) ProtoSize added in v0.14.43

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

func (*CountsSet) Reset added in v0.14.43

func (m *CountsSet) Reset()

func (*CountsSet) String added in v0.14.43

func (m *CountsSet) String() string

func (*CountsSet) Unmarshal added in v0.14.43

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

func (*CountsSet) XXX_DiscardUnknown added in v1.0.1

func (m *CountsSet) XXX_DiscardUnknown()

func (*CountsSet) XXX_Marshal added in v1.0.1

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

func (*CountsSet) XXX_Merge added in v1.0.1

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

func (*CountsSet) XXX_Size added in v1.0.1

func (m *CountsSet) XXX_Size() int

func (*CountsSet) XXX_Unmarshal added in v1.0.1

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

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_syncthing_syncthing_lib_protocol.ShortID `` /* 162-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"`
	// 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 added in v0.14.48

func (f FileInfoTruncated) BlockSize() int

func (FileInfoTruncated) ConvertDeletedToFileInfo added in v1.5.0

func (f FileInfoTruncated) ConvertDeletedToFileInfo() protocol.FileInfo

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

func (FileInfoTruncated) ConvertToDeletedFileInfo added in v1.4.0

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

func (FileInfoTruncated) ConvertToIgnoredFileInfo added in v0.14.49

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

func (*FileInfoTruncated) Descriptor added in v0.14.0

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

func (FileInfoTruncated) FileLocalFlags added in v0.14.50

func (f FileInfoTruncated) FileLocalFlags() uint32

func (FileInfoTruncated) FileModifiedBy added in v1.3.2

func (f FileInfoTruncated) FileModifiedBy() protocol.ShortID

func (FileInfoTruncated) FileName added in v0.14.0

func (f FileInfoTruncated) FileName() string

func (FileInfoTruncated) FilePermissions added in v1.3.2

func (f FileInfoTruncated) FilePermissions() uint32

func (FileInfoTruncated) FileSize added in v0.14.0

func (f FileInfoTruncated) FileSize() int64

func (FileInfoTruncated) FileType added in v1.3.2

func (FileInfoTruncated) FileVersion added in v0.14.49

func (f FileInfoTruncated) FileVersion() protocol.Vector

func (FileInfoTruncated) HasPermissionBits added in v0.14.0

func (f FileInfoTruncated) HasPermissionBits() bool

func (FileInfoTruncated) IsDeleted added in v0.14.0

func (f FileInfoTruncated) IsDeleted() bool

func (FileInfoTruncated) IsDirectory added in v0.14.0

func (f FileInfoTruncated) IsDirectory() bool

func (FileInfoTruncated) IsIgnored added in v0.14.49

func (f FileInfoTruncated) IsIgnored() bool

func (FileInfoTruncated) IsInvalid added in v0.14.0

func (f FileInfoTruncated) IsInvalid() bool

func (FileInfoTruncated) IsReceiveOnlyChanged added in v0.14.50

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

func (FileInfoTruncated) IsUnsupported added in v0.14.50

func (f FileInfoTruncated) IsUnsupported() bool

func (*FileInfoTruncated) Marshal added in v0.14.0

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

func (*FileInfoTruncated) MarshalTo added in v0.14.0

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

func (*FileInfoTruncated) MarshalToSizedBuffer added in v1.3.0

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

func (FileInfoTruncated) ModTime added in v0.14.4

func (f FileInfoTruncated) ModTime() time.Time

func (FileInfoTruncated) MustRescan added in v0.14.49

func (f FileInfoTruncated) MustRescan() bool

func (*FileInfoTruncated) ProtoMessage added in v0.14.0

func (*FileInfoTruncated) ProtoMessage()

func (*FileInfoTruncated) ProtoSize added in v0.14.0

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

func (*FileInfoTruncated) Reset added in v0.14.0

func (m *FileInfoTruncated) Reset()

func (FileInfoTruncated) SequenceNo added in v0.14.43

func (f FileInfoTruncated) SequenceNo() int64

func (FileInfoTruncated) ShouldConflict added in v0.14.51

func (f FileInfoTruncated) ShouldConflict() bool

func (FileInfoTruncated) String added in v0.14.0

func (f FileInfoTruncated) String() string

func (*FileInfoTruncated) Unmarshal added in v0.14.0

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

func (*FileInfoTruncated) XXX_DiscardUnknown added in v1.0.1

func (m *FileInfoTruncated) XXX_DiscardUnknown()

func (*FileInfoTruncated) XXX_Marshal added in v1.0.1

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

func (*FileInfoTruncated) XXX_Merge added in v1.0.1

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

func (*FileInfoTruncated) XXX_Size added in v1.0.1

func (m *FileInfoTruncated) XXX_Size() int

func (*FileInfoTruncated) XXX_Unmarshal added in v1.0.1

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

type FileSet

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

func NewFileSet

func NewFileSet(folder string, fs fs.Filesystem, db *Lowlevel) *FileSet

func (*FileSet) Drop added in v0.14.41

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

func (*FileSet) IndexID added in v0.14.1

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

func (*FileSet) ListDevices added in v0.14.4

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

func (*FileSet) MtimeFS added in v0.14.4

func (s *FileSet) MtimeFS() *fs.MtimeFS

func (*FileSet) RepairSequence added in v1.4.1

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

func (*FileSet) Sequence added in v0.14.4

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

func (*FileSet) SetIndexID added in v0.14.1

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

func (*FileSet) Snapshot added in v1.4.0

func (s *FileSet) Snapshot() *Snapshot

func (*FileSet) Update

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

type FileVersion added in v0.14.0

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 added in v0.14.0

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

func (FileVersion) FirstDevice added in v1.7.0

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

func (FileVersion) IsInvalid added in v1.7.0

func (fv FileVersion) IsInvalid() bool

func (*FileVersion) Marshal added in v0.14.0

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

func (*FileVersion) MarshalTo added in v0.14.0

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

func (*FileVersion) MarshalToSizedBuffer added in v1.3.0

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

func (*FileVersion) ProtoMessage added in v0.14.0

func (*FileVersion) ProtoMessage()

func (*FileVersion) ProtoSize added in v0.14.0

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

func (*FileVersion) Reset added in v0.14.0

func (m *FileVersion) Reset()

func (*FileVersion) String added in v0.14.0

func (m *FileVersion) String() string

func (*FileVersion) Unmarshal added in v0.14.0

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

func (*FileVersion) XXX_DiscardUnknown added in v1.0.1

func (m *FileVersion) XXX_DiscardUnknown()

func (*FileVersion) XXX_Marshal added in v1.0.1

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

func (*FileVersion) XXX_Merge added in v1.0.1

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

func (*FileVersion) XXX_Size added in v1.0.1

func (m *FileVersion) XXX_Size() int

func (*FileVersion) XXX_Unmarshal added in v1.0.1

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

type FileVersionDeprecated added in v1.7.0

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 added in v1.7.0

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

func (*FileVersionDeprecated) Marshal added in v1.7.0

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

func (*FileVersionDeprecated) MarshalTo added in v1.7.0

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

func (*FileVersionDeprecated) MarshalToSizedBuffer added in v1.7.0

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

func (*FileVersionDeprecated) ProtoMessage added in v1.7.0

func (*FileVersionDeprecated) ProtoMessage()

func (*FileVersionDeprecated) ProtoSize added in v1.7.0

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

func (*FileVersionDeprecated) Reset added in v1.7.0

func (m *FileVersionDeprecated) Reset()

func (*FileVersionDeprecated) String added in v1.7.0

func (m *FileVersionDeprecated) String() string

func (*FileVersionDeprecated) Unmarshal added in v1.7.0

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

func (*FileVersionDeprecated) XXX_DiscardUnknown added in v1.7.0

func (m *FileVersionDeprecated) XXX_DiscardUnknown()

func (*FileVersionDeprecated) XXX_Marshal added in v1.7.0

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

func (*FileVersionDeprecated) XXX_Merge added in v1.7.0

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

func (*FileVersionDeprecated) XXX_Size added in v1.7.0

func (m *FileVersionDeprecated) XXX_Size() int

func (*FileVersionDeprecated) XXX_Unmarshal added in v1.7.0

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

type IndirectionHashesOnly added in v1.7.0

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 added in v1.7.0

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

func (*IndirectionHashesOnly) Marshal added in v1.7.0

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

func (*IndirectionHashesOnly) MarshalTo added in v1.7.0

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

func (*IndirectionHashesOnly) MarshalToSizedBuffer added in v1.7.0

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

func (*IndirectionHashesOnly) ProtoMessage added in v1.7.0

func (*IndirectionHashesOnly) ProtoMessage()

func (*IndirectionHashesOnly) ProtoSize added in v1.7.0

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

func (*IndirectionHashesOnly) Reset added in v1.7.0

func (m *IndirectionHashesOnly) Reset()

func (*IndirectionHashesOnly) String added in v1.7.0

func (m *IndirectionHashesOnly) String() string

func (*IndirectionHashesOnly) Unmarshal added in v1.7.0

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

func (*IndirectionHashesOnly) XXX_DiscardUnknown added in v1.7.0

func (m *IndirectionHashesOnly) XXX_DiscardUnknown()

func (*IndirectionHashesOnly) XXX_Marshal added in v1.7.0

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

func (*IndirectionHashesOnly) XXX_Merge added in v1.7.0

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

func (*IndirectionHashesOnly) XXX_Size added in v1.7.0

func (m *IndirectionHashesOnly) XXX_Size() int

func (*IndirectionHashesOnly) XXX_Unmarshal added in v1.7.0

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 added in v0.14.52

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 added in v0.14.52

func NewLowlevel(backend backend.Backend, opts ...Option) *Lowlevel

func (*Lowlevel) ListFolders added in v0.14.52

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

ListFolders returns the list of folders currently in the database

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 added in v0.14.52

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

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

func NewFolderStatisticsNamespace added in v0.14.52

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

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

func NewMiscDataNamespace added in v0.14.52

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 Option added in v1.5.0

type Option func(*Lowlevel)

func WithIndirectGCInterval added in v1.5.0

func WithIndirectGCInterval(dur time.Duration) Option

WithIndirectGCInterval sets the time interval in between GC runs.

func WithRecheckInterval added in v1.5.0

func WithRecheckInterval(dur time.Duration) Option

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

type Snapshot added in v1.4.0

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

func (*Snapshot) Availability added in v1.4.0

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

func (*Snapshot) Get added in v1.4.0

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

func (*Snapshot) GetGlobal added in v1.4.0

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

func (*Snapshot) GetGlobalTruncated added in v1.4.0

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

func (*Snapshot) GlobalSize added in v1.4.0

func (s *Snapshot) GlobalSize() Counts

func (*Snapshot) LocalChangedFiles added in v1.4.0

func (s *Snapshot) LocalChangedFiles(page, perpage int) []FileInfoTruncated

LocalChangedFiles returns a paginated list of files that were changed locally.

func (*Snapshot) LocalSize added in v1.4.0

func (s *Snapshot) LocalSize() Counts

func (*Snapshot) NeedSize added in v1.4.0

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

func (*Snapshot) ReceiveOnlyChangedSize added in v1.4.0

func (s *Snapshot) ReceiveOnlyChangedSize() Counts

func (*Snapshot) Release added in v1.4.0

func (s *Snapshot) Release()

func (*Snapshot) RemoteNeedFolderFiles added in v1.4.0

func (s *Snapshot) RemoteNeedFolderFiles(device protocol.DeviceID, page, perpage int) []FileInfoTruncated

RemoteNeedFolderFiles returns paginated list of currently needed files in progress, queued, and to be queued on next puller iteration, as well as the total number of files currently needed.

func (*Snapshot) RemoteSequence added in v1.4.0

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 added in v1.4.0

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

func (*Snapshot) WithBlocksHash added in v1.6.0

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

func (*Snapshot) WithGlobal added in v1.4.0

func (s *Snapshot) WithGlobal(fn Iterator)

func (*Snapshot) WithGlobalTruncated added in v1.4.0

func (s *Snapshot) WithGlobalTruncated(fn Iterator)

func (*Snapshot) WithHave added in v1.4.0

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

func (*Snapshot) WithHaveSequence added in v1.4.0

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

func (*Snapshot) WithHaveTruncated added in v1.4.0

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

func (*Snapshot) WithNeed added in v1.4.0

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

func (*Snapshot) WithNeedTruncated added in v1.4.0

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

func (*Snapshot) WithPrefixedGlobalTruncated added in v1.4.0

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 added in v1.4.0

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 added in v0.13.5

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

func (*VersionList) Descriptor added in v0.14.0

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

func (*VersionList) Empty added in v1.7.0

func (vl *VersionList) Empty() bool

func (*VersionList) Get added in v0.14.49

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 added in v1.7.0

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 added in v0.14.0

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

func (*VersionList) MarshalTo added in v0.14.0

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

func (*VersionList) MarshalToSizedBuffer added in v1.3.0

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

func (*VersionList) ProtoMessage added in v0.14.0

func (*VersionList) ProtoMessage()

func (*VersionList) ProtoSize added in v0.14.0

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

func (*VersionList) Reset added in v0.14.0

func (m *VersionList) Reset()

func (VersionList) String added in v0.13.5

func (vl VersionList) String() string

func (*VersionList) Unmarshal added in v0.14.0

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

func (*VersionList) XXX_DiscardUnknown added in v1.0.1

func (m *VersionList) XXX_DiscardUnknown()

func (*VersionList) XXX_Marshal added in v1.0.1

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

func (*VersionList) XXX_Merge added in v1.0.1

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

func (*VersionList) XXX_Size added in v1.0.1

func (m *VersionList) XXX_Size() int

func (*VersionList) XXX_Unmarshal added in v1.0.1

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

type VersionListDeprecated added in v1.7.0

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

func (*VersionListDeprecated) Descriptor added in v1.7.0

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

func (*VersionListDeprecated) Get added in v1.7.0

func (*VersionListDeprecated) Marshal added in v1.7.0

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

func (*VersionListDeprecated) MarshalTo added in v1.7.0

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

func (*VersionListDeprecated) MarshalToSizedBuffer added in v1.7.0

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

func (*VersionListDeprecated) ProtoMessage added in v1.7.0

func (*VersionListDeprecated) ProtoMessage()

func (*VersionListDeprecated) ProtoSize added in v1.7.0

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

func (*VersionListDeprecated) Reset added in v1.7.0

func (m *VersionListDeprecated) Reset()

func (*VersionListDeprecated) String added in v1.7.0

func (vl *VersionListDeprecated) String() string

func (*VersionListDeprecated) Unmarshal added in v1.7.0

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

func (*VersionListDeprecated) XXX_DiscardUnknown added in v1.7.0

func (m *VersionListDeprecated) XXX_DiscardUnknown()

func (*VersionListDeprecated) XXX_Marshal added in v1.7.0

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

func (*VersionListDeprecated) XXX_Merge added in v1.7.0

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

func (*VersionListDeprecated) XXX_Size added in v1.7.0

func (m *VersionListDeprecated) XXX_Size() int

func (*VersionListDeprecated) XXX_Unmarshal added in v1.7.0

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