Files
syncthing-arm/internal/model/.model.go.swp

22 lines
16 KiB
Plaintext
Raw Normal View History

b0VIM 7.4!ZEU<45><55><EFBFBD><00>lhostemb5-btrfs/data/Sync-Projects/golang-workspace/src/github.com/syncthing/syncthing/internal/model/model.go 3210#"! U
<00> <00> u @    <00> <00> j <00>
<00>
a
_
^
E
<
4
<00> <00> <00> <00> <00> o m l X 7  <00><00><00><00><00><00>oYX<00>H<00><00>(<00>e<00><00>ED2 <00><00><00><00>S<00><00>mU%<00><00><00><00> shortID: id.Short(), id: id, progressEmitter: NewProgressEmitter(cfg), finder: db.NewBlockFinder(ldb, cfg), db: ldb, cfg: cfg, m := &Model{func NewModel(cfg *config.Wrapper, id protocol.DeviceID, deviceName, clientName, clientVersion string, ldb *leveldb.DB) *Model {// for file data without altering the local folder in any way.// where it sends index information to connected peers and responds to requests// NewModel creates and starts a new model. The model starts in read-only mode,) SymlinkWarning = stdsync.Once{}var (} started bool addedFolder bool pmut sync.RWMutex // protects protoConn and rawConn deviceVer map[protocol.DeviceID]string rawConn map[protocol.DeviceID]io.Closer protoConn map[protocol.DeviceID]protocol.Connection fmut sync.RWMutex // protects the above folderStatRefs map[string]*stats.FolderStatisticsReference // folder -> statsRef folderRunners map[string]service // folder -> puller or scanner folderIgnores map[string]*ignore.Matcher // folder -> matcher object deviceStatRefs map[protocol.DeviceID]*stats.DeviceStatisticsReference // deviceID -> statsRef deviceFolders map[protocol.DeviceID][]string // deviceID -> folders folderDevices map[string][]protocol.DeviceID // folder -> deviceIDs folderFiles map[string]*db.FileSet // folder -> files folderCfgs map[string]config.FolderConfiguration // folder -> cfg clientVersion string clientName string deviceName string shortID uint64 id protocol.DeviceID progressEmitter *ProgressEmitter finder *db.BlockFinder db *leveldb.DB cfg *config.Wrappertype Model struct {} getState() (folderState, time.Time, error) setError(err error) setState(state folderState) DelayScan(d time.Duration) BringToFront(string) Jobs() ([]string, []string) // In progress, Queued Stop() Serve()type service interface {) indexBatchSize = 1000 // Either way, don't include more files than this IndexPerBlockSize = 40 // Each BlockInfo is approximately this big indexPerFileSize = 250 // Each FileInfo is approximately this big, in bytes, excluding BlockInfos indexTargetSize = 250 * 1024 // Aim for making index messages no larger than 250 KiB (uncompressed)const (// How many files to send in each Index/IndexUpdate message.) "github.com/syndtr/goleveldb/leveldb" "github.com/syncthing/syncthing/internal/versioner" "github.com/syncthing/syncthing/internal/sync" "github.com/syncthing/syncthing/internal/symlinks" "github.com/syncthing/syncthing/internal/stats" "github.com/syncthing/syncthing/internal/scanner" "github.com/syncthing/syncthing/internal/osutil" "github.com/syncthing/syncthing/internal/ignore" "github.com/syncthing/syncthing/internal/events" "github.com/syncthing/syncthing/internal/db" "github.com/syncthing/syncthing/internal/config" "github.com/syncthing/protocol" "time" stdsync "sync" "strings" "runtime" "path/filepath" "os" "net" "io/ioutil" "io" "fmt" "errors" "encoding/json" "crypto/tls" "bufio"import (package model// You can obtain one at http://mozilla.org/MPL/2.0/.// License, v. 2.0. If a copy of the MPL was not distributed with this file,// This Source Code Form is subject to the terms of the Mozilla Public//// Copyright (C) 2014 The Syncthing Authors.adueu<00><00><00><00><00><00>~}<<00><00><00><00><00><00><00><00><00>D
<00> <00> <00> { x w T 0 <00> <00> q M ,  <00> <00> <00> <00> N ) <00>
<00>
<00>
<00>
d
7




<00> <00> <00> <00> <00> v s r a + <00><00><00><00>ya]B<00><00><00><00><00><00><00><00><00>\I<00><00><00><00><00><00><00><00>kih@<00>toa^PNM<00><00>hY<00><00><00><00><00>ged} return data[skip : skip+get], 0, 0 } return data[skip:l], 0, get - (l - skip) } else if l < skip+get { return []string{}, skip - l, get if l <= skip { l := len(data)func getChunk(data []string, skip, get int) ([]string, int, int) {// big enough.// copy to satisfy the values which were provided, given the slice is not// Returns the resulting slice, plus how much elements are left to skip or// Skips `skip` elements and retrieves up to `get` elements from a given slice.} return false } return true }) l.Warnln("Symlinks are disabled, unsupported or require Administrator privileges. This might cause your folder to appear out of sync.") SymlinkWarning.Do(func() { if !symlinks.Supported && isLink {func symlinkInvalid(isLink bool) bool {} return fmt.Sprintf("model@%p", m)func (m *Model) String() string {} return fmt.Errorf("Unknown folder %q", folder) } } return nil db.DropFolder(m.db, folder) l.Infof("Cleaning data for folder %q", folder) if f == folder { for _, f := range db.ListFolders(m.db) {func (m *Model) ResetFolder(folder string) error {} return err } } runner.setState(FolderIdle) if runnerExists { l.Infof("Folder %q error is cleared, restarting", folder.ID) } else if oldErr != nil { } runner.setError(err) if runnerExists { } l.Warnf("Stopping folder %q - %v", folder.ID, err) } else if oldErr == nil { l.Infof("Folder %q error changed: %q -> %q", folder.ID, oldErr, err) if oldErr != nil && oldErr.Error() != err.Error() { if err != nil { } _, _, oldErr = runner.getState() if runnerExists { var oldErr error m.fmut.RUnlock() runner, runnerExists := m.folderRunners[folder.ID] m.fmut.RLock() } err = folder.CreateMarker() // but the marker is not there, create it. // If we don't have any files in the index, and the path does exist } else if !folder.HasMarker() { } err = folder.CreateMarker() if err == nil { err = os.MkdirAll(folder.Path(), 0700) // doesn't exist, try creating it. // If we don't have any files in the index, and the directory } else if os.IsNotExist(err) { } err = errors.New("folder marker missing") } else if !folder.HasMarker() { err = errors.New("folder path missing") if err != nil || !fi.IsDir() { // so mark it as invalid instead. // that all files have been deleted which might not be the case, // folder doesn't exist, we have a problem. We would assume // Safety check. If the cached index contains files but the if m.CurrentLocalVersion(id) > 0 { fi, err := os.Stat(folder.Path()) } return errors.New("folder does not exist") if !ok { folder, ok := m.cfg.Folders()[id]func (m *Model) CheckFolderHealth(id string) error {// current folder error, or nil if the folder is healthy.// CheckFolderHealth checks the folder for common errors and returns the} } runner.BringToFront(file) if ok { runner, ok := m.folderRunners[folder] defer m.pmut.RUnlock() m.pmut.RLock()func (m *Model) BringToFront(folder, file string) {// BringToFront bumps the given files priority in the job queue.} return availableDevices } } availableDevices = append(availableDevices, device) if ok { _, ok := m.protoConn[device]