Documentation ¶
Overview ¶
Package model implements folder abstraction and file pulling mechanisms
Index ¶
- Constants
- Variables
- type Availability
- type ConnectionInfo
- type FileError
- type FolderCompletion
- type FolderSummaryService
- type Holdable
- type Model
- type ProgressEmitter
- func (t *ProgressEmitter) BytesCompleted(folder string) (bytes int64)
- func (t *ProgressEmitter) CommitConfiguration(from, to config.Configuration) bool
- func (t *ProgressEmitter) Deregister(s *sharedPullerState)
- func (t *ProgressEmitter) Register(s *sharedPullerState)
- func (t *ProgressEmitter) String() string
- func (t *ProgressEmitter) VerifyConfiguration(from, to config.Configuration) error
Constants ¶
const ( FolderIdle folderState = iota FolderScanning FolderScanWaiting FolderSyncing FolderError )
Variables ¶
var (
ErrFolderPaused = errors.New("folder is paused")
)
Functions ¶
This section is empty.
Types ¶
type Availability ¶ added in v0.13.0
type ConnectionInfo ¶
type ConnectionInfo struct { protocol.Statistics Connected bool Paused bool Address string ClientVersion string Type string Crypto string }
func (ConnectionInfo) MarshalJSON ¶
func (info ConnectionInfo) MarshalJSON() ([]byte, error)
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 NeedBytes int64 NeedItems int64 GlobalBytes int64 NeedDeletes int64 }
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 FolderSummaryService ¶ added in v1.1.2
type FolderSummaryService interface { suture.Service Summary(folder string) (map[string]interface{}, error) OnEventRequest() }
func NewFolderSummaryService ¶ added in v1.1.2
type Model ¶
type Model interface { suture.Service connections.Model AddFolder(cfg config.FolderConfiguration) RestartFolder(from, to config.FolderConfiguration) StartFolder(folder string) ResetFolder(folder string) 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) GetIgnores(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]string, error) LocalChangedFiles(folder string, page, perpage int) []db.FileInfoTruncated NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated) RemoteNeedFolderFiles(device protocol.DeviceID, folder string, page, perpage int) ([]db.FileInfoTruncated, error) CurrentFolderFile(folder string, file string) (protocol.FileInfo, bool) CurrentGlobalFile(folder string, file string) (protocol.FileInfo, bool) Availability(folder string, file protocol.FileInfo, block protocol.BlockInfo) []Availability GlobalSize(folder string) db.Counts LocalSize(folder string) db.Counts NeedSize(folder string) db.Counts ReceiveOnlyChangedSize(folder string) db.Counts CurrentSequence(folder string) (int64, bool) RemoteSequence(folder string) (int64, bool) Completion(device protocol.DeviceID, folder string) FolderCompletion ConnectionStats() map[string]interface{} DeviceStatistics() map[string]stats.DeviceStatistics FolderStatistics() map[string]stats.FolderStatistics UsageReportingStats(version int, preview bool) map[string]interface{} StartDeadlockDetector(timeout time.Duration) GlobalDirectoryTree(folder, prefix string, levels int, dirsonly bool) map[string]interface{} }
func NewModel ¶
func NewModel(cfg config.Wrapper, id protocol.DeviceID, clientName, clientVersion string, ldb *db.Lowlevel, protectedFiles []string, evLogger events.Logger) 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 ¶
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(from, 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) String ¶
func (t *ProgressEmitter) String() string
func (*ProgressEmitter) VerifyConfiguration ¶
func (t *ProgressEmitter) VerifyConfiguration(from, to config.Configuration) error
VerifyConfiguration implements the config.Committer interface