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.
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
- func BlocksToSize(num int) int64
- func DropFolder(db *leveldb.DB, folder string)
- func ListFolders(db *leveldb.DB) []string
- type BlockFinder
- func (f *BlockFinder) CommitConfiguration(from, to config.Configuration) bool
- func (f *BlockFinder) Fix(folder, file string, index int32, oldHash, newHash []byte) error
- func (f *BlockFinder) Iterate(hash []byte, iterFn func(string, string, int32) bool) bool
- func (f *BlockFinder) String() string
- func (f *BlockFinder) VerifyConfiguration(from, to config.Configuration) error
- type BlockMap
- type FileInfoTruncated
- type FileIntf
- type FileSet
- func (s *FileSet) Availability(file string) []protocol.DeviceID
- func (s *FileSet) Get(device protocol.DeviceID, file string) (protocol.FileInfo, bool)
- func (s *FileSet) GetGlobal(file string) (protocol.FileInfo, bool)
- func (s *FileSet) GetGlobalTruncated(file string) (FileInfoTruncated, bool)
- func (s *FileSet) LocalVersion(device protocol.DeviceID) int64
- func (s *FileSet) Replace(device protocol.DeviceID, fs []protocol.FileInfo)
- func (s *FileSet) ReplaceWithDelete(device protocol.DeviceID, fs []protocol.FileInfo, myID uint64)
- func (s *FileSet) Update(device protocol.DeviceID, fs []protocol.FileInfo)
- func (s *FileSet) WithGlobal(fn Iterator)
- func (s *FileSet) WithGlobalTruncated(fn Iterator)
- func (s *FileSet) WithHave(device protocol.DeviceID, fn Iterator)
- func (s *FileSet) WithHaveTruncated(device protocol.DeviceID, fn Iterator)
- func (s *FileSet) WithNeed(device protocol.DeviceID, fn Iterator)
- func (s *FileSet) WithNeedTruncated(device protocol.DeviceID, fn Iterator)
- func (s *FileSet) WithPrefixedGlobalTruncated(prefix string, fn Iterator)
- type Iterator
- type NamespacedKV
- func (n NamespacedKV) Bool(key string) (bool, bool)
- func (n NamespacedKV) Bytes(key string) ([]byte, bool)
- func (n NamespacedKV) Delete(key string)
- func (n *NamespacedKV) Int64(key string) (int64, bool)
- func (n *NamespacedKV) PutBool(key string, val bool)
- func (n *NamespacedKV) PutBytes(key string, val []byte)
- func (n *NamespacedKV) PutInt64(key string, val int64)
- func (n *NamespacedKV) PutString(key, val string)
- func (n *NamespacedKV) PutTime(key string, val time.Time)
- func (n *NamespacedKV) Reset()
- func (n NamespacedKV) String(key string) (string, bool)
- func (n NamespacedKV) Time(key string) (time.Time, bool)
- type VirtualMtimeRepo
Constants ¶
const ( KeyTypeDevice = iota KeyTypeGlobal KeyTypeBlock KeyTypeDeviceStatistic KeyTypeFolderStatistic KeyTypeVirtualMtime )
Variables ¶
This section is empty.
Functions ¶
func BlocksToSize ¶
func DropFolder ¶
DropFolder clears out all information related to the given folder from the database.
func ListFolders ¶
ListFolders returns the folder IDs seen in the database.
Types ¶
type BlockFinder ¶
type BlockFinder struct {
// contains filtered or unexported fields
}
func NewBlockFinder ¶
func NewBlockFinder(db *leveldb.DB, cfg *config.Wrapper) *BlockFinder
func (*BlockFinder) CommitConfiguration ¶ added in v0.11.9
func (f *BlockFinder) CommitConfiguration(from, to config.Configuration) bool
CommitConfiguration implementes the config.Committer interface
func (*BlockFinder) Fix ¶
func (f *BlockFinder) Fix(folder, file string, index int32, oldHash, newHash []byte) error
Fix repairs incorrect blockmap entries, removing the old entry and replacing it with a new entry for the given block
func (*BlockFinder) Iterate ¶
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 ¶ added in v0.11.9
func (f *BlockFinder) String() string
func (*BlockFinder) VerifyConfiguration ¶ added in v0.11.9
func (f *BlockFinder) VerifyConfiguration(from, to config.Configuration) error
VerifyConfiguration implementes the config.Committer interface
type BlockMap ¶
type BlockMap struct {
// contains filtered or unexported fields
}
type FileInfoTruncated ¶
func (FileInfoTruncated) Size ¶
func (f FileInfoTruncated) Size() int64
func (*FileInfoTruncated) UnmarshalXDR ¶
func (f *FileInfoTruncated) UnmarshalXDR(bs []byte) error
type FileIntf ¶
type FileIntf interface { Size() int64 IsDeleted() bool IsInvalid() bool IsDirectory() bool IsSymlink() bool HasPermissionBits() bool }
FileIntf is the set of methods implemented by both protocol.FileInfo and protocol.FileInfoTruncated.
type FileSet ¶
type FileSet struct {
// contains filtered or unexported fields
}
func (*FileSet) GetGlobalTruncated ¶
func (s *FileSet) GetGlobalTruncated(file string) (FileInfoTruncated, bool)
func (*FileSet) ReplaceWithDelete ¶
func (*FileSet) WithGlobal ¶
func (*FileSet) WithGlobalTruncated ¶
func (*FileSet) WithHaveTruncated ¶
func (*FileSet) WithNeedTruncated ¶
func (*FileSet) WithPrefixedGlobalTruncated ¶ added in v0.10.25
type Iterator ¶
The Iterator is called with either a protocol.FileInfo or a protocol.FileInfoTruncated (depending on the method) and returns true to continue iteration, false to stop.
type NamespacedKV ¶ added in v0.10.24
type NamespacedKV struct {
// contains filtered or unexported fields
}
NamespacedKV is a simple key-value store using a specific namespace within a leveldb.
func NewNamespacedKV ¶ added in v0.10.24
func NewNamespacedKV(db *leveldb.DB, prefix string) *NamespacedKV
NewNamespacedKV returns a new NamespacedKV that lives in the namespace specified by the prefix.
func (NamespacedKV) Bool ¶ added in v0.11.10
func (n NamespacedKV) Bool(key string) (bool, bool)
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 ¶ added in v0.11.4
func (n NamespacedKV) Bytes(key string) ([]byte, bool)
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 ¶ added in v0.10.24
func (n NamespacedKV) Delete(key string)
Delete deletes the specified key. It is allowed to delete a nonexistent key.
func (*NamespacedKV) Int64 ¶ added in v0.10.24
func (n *NamespacedKV) Int64(key string) (int64, bool)
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 ¶ added in v0.11.10
func (n *NamespacedKV) PutBool(key string, val bool)
PutBool stores a new boolean. Any existing value (even if of another type) is overwritten.
func (*NamespacedKV) PutBytes ¶ added in v0.11.4
func (n *NamespacedKV) PutBytes(key string, val []byte)
PutBytes stores a new byte slice. Any existing value (even if of another type) is overwritten.
func (*NamespacedKV) PutInt64 ¶ added in v0.10.24
func (n *NamespacedKV) PutInt64(key string, val int64)
PutInt64 stores a new int64. Any existing value (even if of another type) is overwritten.
func (*NamespacedKV) PutString ¶ added in v0.10.24
func (n *NamespacedKV) PutString(key, val string)
PutString stores a new string. Any existing value (even if of another type) is overwritten.
func (*NamespacedKV) PutTime ¶ added in v0.10.24
func (n *NamespacedKV) PutTime(key string, val time.Time)
PutTime stores a new time.Time. Any existing value (even if of another type) is overwritten.
func (*NamespacedKV) Reset ¶ added in v0.11.4
func (n *NamespacedKV) Reset()
Reset removes all entries in this namespace.
type VirtualMtimeRepo ¶ added in v0.11.4
type VirtualMtimeRepo struct {
// contains filtered or unexported fields
}
func NewVirtualMtimeRepo ¶ added in v0.11.4
func NewVirtualMtimeRepo(ldb *leveldb.DB, folder string) *VirtualMtimeRepo
func (*VirtualMtimeRepo) DeleteMtime ¶ added in v0.11.4
func (r *VirtualMtimeRepo) DeleteMtime(path string)
func (*VirtualMtimeRepo) Drop ¶ added in v0.11.4
func (r *VirtualMtimeRepo) Drop()
func (*VirtualMtimeRepo) UpdateMtime ¶ added in v0.11.4
func (r *VirtualMtimeRepo) UpdateMtime(path string, diskMtime, actualMtime time.Time)