Documentation ¶
Overview ¶
Package model implements folder abstraction and file pulling mechanisms
Index ¶
- Constants
- Variables
- type Availability
- type ClusterConfigReceivedEventData
- type ConnectionInfo
- type ConnectionStats
- type FileError
- type FolderCompletion
- type FolderSummary
- type FolderSummaryEventData
- type FolderSummaryService
- type Holdable
- type Model
- type ProgressEmitter
- func (t *ProgressEmitter) BytesCompleted(folder string) (bytes int64)
- func (t *ProgressEmitter) CommitConfiguration(_, to config.Configuration) bool
- func (t *ProgressEmitter) Deregister(s *sharedPullerState)
- func (t *ProgressEmitter) Register(s *sharedPullerState)
- func (t *ProgressEmitter) Serve(ctx context.Context) error
- func (t *ProgressEmitter) String() string
- type TreeEntry
Constants ¶
const ( FolderIdle folderState = iota FolderScanning FolderScanWaiting FolderSyncWaiting FolderSyncPreparing FolderSyncing FolderCleaning FolderCleanWaiting FolderError )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Availability ¶ added in v0.13.0
type ClusterConfigReceivedEventData ¶ added in v1.20.0
type ConnectionInfo ¶
type ConnectionStats ¶ added in v1.25.0
type ConnectionStats struct { protocol.Statistics // Total for primary + secondaries Connected bool `json:"connected"` Paused bool `json:"paused"` ClientVersion string `json:"clientVersion"` Address string `json:"address"` // mirror values from Primary, for compatibility with <1.24.0 Type string `json:"type"` // mirror values from Primary, for compatibility with <1.24.0 IsLocal bool `json:"isLocal"` // mirror values from Primary, for compatibility with <1.24.0 Crypto string `json:"crypto"` // mirror values from Primary, for compatibility with <1.24.0 Primary ConnectionInfo `json:"primary,omitempty"` Secondary []ConnectionInfo `json:"secondary,omitempty"` }
type FileError ¶ added in v0.14.44
A []FileError is sent as part of an event and will be JSON serialized.
type FolderCompletion ¶ added in v0.14.5
type FolderCompletion struct { CompletionPct float64 GlobalBytes int64 NeedBytes int64 GlobalItems int NeedItems int NeedDeletes int Sequence int64 RemoteState remoteFolderState }
func (*FolderCompletion) Map ¶ added in v1.1.2
func (comp *FolderCompletion) Map() map[string]interface{}
Map returns the members as a map, e.g. used in api to serialize as JSON.
type FolderSummary ¶ added in v1.20.0
type FolderSummary struct { Errors int `json:"errors"` PullErrors int `json:"pullErrors"` // deprecated Invalid string `json:"invalid"` // deprecated GlobalFiles int `json:"globalFiles"` GlobalDirectories int `json:"globalDirectories"` GlobalSymlinks int `json:"globalSymlinks"` GlobalDeleted int `json:"globalDeleted"` GlobalBytes int64 `json:"globalBytes"` GlobalTotalItems int `json:"globalTotalItems"` LocalFiles int `json:"localFiles"` LocalDirectories int `json:"localDirectories"` LocalSymlinks int `json:"localSymlinks"` LocalDeleted int `json:"localDeleted"` LocalBytes int64 `json:"localBytes"` LocalTotalItems int `json:"localTotalItems"` NeedFiles int `json:"needFiles"` NeedDirectories int `json:"needDirectories"` NeedSymlinks int `json:"needSymlinks"` NeedDeletes int `json:"needDeletes"` NeedBytes int64 `json:"needBytes"` NeedTotalItems int `json:"needTotalItems"` ReceiveOnlyChangedFiles int `json:"receiveOnlyChangedFiles"` ReceiveOnlyChangedDirectories int `json:"receiveOnlyChangedDirectories"` ReceiveOnlyChangedSymlinks int `json:"receiveOnlyChangedSymlinks"` ReceiveOnlyChangedDeletes int `json:"receiveOnlyChangedDeletes"` ReceiveOnlyChangedBytes int64 `json:"receiveOnlyChangedBytes"` ReceiveOnlyTotalItems int `json:"receiveOnlyTotalItems"` InSyncFiles int `json:"inSyncFiles"` InSyncBytes int64 `json:"inSyncBytes"` State string `json:"state"` StateChanged time.Time `json:"stateChanged"` Error string `json:"error"` Version int64 `json:"version"` // deprecated Sequence int64 `json:"sequence"` IgnorePatterns bool `json:"ignorePatterns"` WatchError string `json:"watchError"` }
FolderSummary replaces the previously used map[string]interface{}, and needs to keep the structure/naming for api backwards compatibility
type FolderSummaryEventData ¶ added in v1.20.0
type FolderSummaryEventData struct { Folder string `json:"folder"` Summary *FolderSummary `json:"summary"` }
type FolderSummaryService ¶ added in v1.1.2
type FolderSummaryService interface { suture.Service Summary(folder string) (*FolderSummary, error) OnEventRequest() }
func NewFolderSummaryService ¶ added in v1.1.2
type Model ¶
type Model interface { suture.Service connections.Model ResetFolder(folder string) error DelayScan(folder string, next time.Duration) ScanFolder(folder string) error ScanFolders() map[string]error ScanFolderSubdirs(folder string, subs []string) error State(folder string) (string, time.Time, error) FolderErrors(folder string) ([]FileError, error) WatchError(folder string) error Override(folder string) Revert(folder string) BringToFront(folder, file string) LoadIgnores(folder string) ([]string, []string, error) CurrentIgnores(folder string) ([]string, []string, error) SetIgnores(folder string, content []string) error GetFolderVersions(folder string) (map[string][]versioner.FileVersion, error) RestoreFolderVersions(folder string, versions map[string]time.Time) (map[string]error, error) DBSnapshot(folder string) (*db.Snapshot, error) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated, error) RemoteNeedFolderFiles(folder string, device protocol.DeviceID, page, perpage int) ([]db.FileInfoTruncated, error) LocalChangedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, error) FolderProgressBytesCompleted(folder string) int64 CurrentFolderFile(folder string, file string) (protocol.FileInfo, bool, error) CurrentGlobalFile(folder string, file string) (protocol.FileInfo, bool, error) GetMtimeMapping(folder string, file string) (fs.MtimeMapping, error) Availability(folder string, file protocol.FileInfo, block protocol.BlockInfo) ([]Availability, error) Completion(device protocol.DeviceID, folder string) (FolderCompletion, error) ConnectionStats() map[string]interface{} DeviceStatistics() (map[protocol.DeviceID]stats.DeviceStatistics, error) FolderStatistics() (map[string]stats.FolderStatistics, error) UsageReportingStats(report *contract.Report, version int, preview bool) ConnectedTo(remoteID protocol.DeviceID) bool PendingDevices() (map[protocol.DeviceID]db.ObservedDevice, error) PendingFolders(device protocol.DeviceID) (map[string]db.PendingFolder, error) DismissPendingDevice(device protocol.DeviceID) error DismissPendingFolder(device protocol.DeviceID, folder string) error StartDeadlockDetector(timeout time.Duration) GlobalDirectoryTree(folder, prefix string, levels int, dirsOnly bool) ([]*TreeEntry, error) }
func NewModel ¶
func NewModel(cfg config.Wrapper, id protocol.DeviceID, ldb *db.Lowlevel, protectedFiles []string, evLogger events.Logger, keyGen *protocol.KeyGenerator) Model
NewModel creates and starts a new model. The model starts in read-only mode, where it sends index information to connected peers and responds to requests for file data without altering the local folder in any way.
type ProgressEmitter ¶
type ProgressEmitter struct {
// contains filtered or unexported fields
}
func NewProgressEmitter ¶
func NewProgressEmitter(cfg config.Wrapper, evLogger events.Logger) *ProgressEmitter
NewProgressEmitter creates a new progress emitter which emits DownloadProgress events every interval.
func (*ProgressEmitter) BytesCompleted ¶
func (t *ProgressEmitter) BytesCompleted(folder string) (bytes int64)
BytesCompleted returns the number of bytes completed in the given folder.
func (*ProgressEmitter) CommitConfiguration ¶
func (t *ProgressEmitter) CommitConfiguration(_, to config.Configuration) bool
CommitConfiguration implements the config.Committer interface
func (*ProgressEmitter) Deregister ¶
func (t *ProgressEmitter) Deregister(s *sharedPullerState)
Deregister a puller which will stop broadcasting pullers state.
func (*ProgressEmitter) Register ¶
func (t *ProgressEmitter) Register(s *sharedPullerState)
Register a puller with the emitter which will start broadcasting pullers progress.
func (*ProgressEmitter) Serve ¶
func (t *ProgressEmitter) Serve(ctx context.Context) error
serve starts the progress emitter which starts emitting DownloadProgress events as the progress happens.
func (*ProgressEmitter) String ¶
func (t *ProgressEmitter) String() string
Source Files ¶
- blockpullreorderer.go
- debug.go
- deviceactivity.go
- devicedownloadstate.go
- doc.go
- folder.go
- folder_recvenc.go
- folder_recvonly.go
- folder_sendonly.go
- folder_sendrecv.go
- folder_sendrecv_unix.go
- folder_summary.go
- folderstate.go
- indexhandler.go
- metrics.go
- model.go
- progressemitter.go
- queue.go
- sentdownloadstate.go
- service_map.go
- sharedpullerstate.go
- util.go