diff options
author | Jakob Borg <jakob@nym.se> | 2014-05-04 18:20:25 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-05-04 18:22:59 +0200 |
commit | f39e10510123f495d587a37c9f7dcb094af3782e (patch) | |
tree | 6c2b72cde69906ca721c6201e6260e67cdc2eb1a /cmd | |
parent | 482795bab0b9a15cfc41316d5cb2c07b35e4c852 (diff) |
Stop repository if the directory disappears (fixes #154)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/syncthing/config.go | 10 | ||||
-rw-r--r-- | cmd/syncthing/model.go | 8 | ||||
-rw-r--r-- | cmd/syncthing/puller.go | 12 |
3 files changed, 26 insertions, 4 deletions
diff --git a/cmd/syncthing/config.go b/cmd/syncthing/config.go index a5a089835a..7422b60c4f 100644 --- a/cmd/syncthing/config.go +++ b/cmd/syncthing/config.go @@ -285,3 +285,13 @@ func ensureNodePresent(nodes []NodeConfiguration, myID string) []NodeConfigurati return nodes } + +func invalidateRepo(repoID string, err error) { + for i := range cfg.Repositories { + repo := &cfg.Repositories[i] + if repo.ID == repoID { + repo.Invalid = err.Error() + return + } + } +} diff --git a/cmd/syncthing/model.go b/cmd/syncthing/model.go index 4356998f73..bda17b36bd 100644 --- a/cmd/syncthing/model.go +++ b/cmd/syncthing/model.go @@ -559,7 +559,7 @@ func (m *Model) ScanRepos() { } } -func (m *Model) ScanRepo(repo string) { +func (m *Model) ScanRepo(repo string) error { sup := &suppressor{threshold: int64(cfg.Options.MaxChangeKbps)} m.rmut.RLock() w := &scanner.Walker{ @@ -572,9 +572,13 @@ func (m *Model) ScanRepo(repo string) { } m.rmut.RUnlock() m.setState(repo, RepoScanning) - fs, _ := w.Walk() + fs, _, err := w.Walk() + if err != nil { + return err + } m.ReplaceLocal(repo, fs) m.setState(repo, RepoIdle) + return nil } func (m *Model) SaveIndexes(dir string) { diff --git a/cmd/syncthing/puller.go b/cmd/syncthing/puller.go index b95961d4bf..20708c40d1 100644 --- a/cmd/syncthing/puller.go +++ b/cmd/syncthing/puller.go @@ -173,7 +173,11 @@ func (p *puller) run() { if debugPull { dlog.Printf("%q: time for rescan", p.repo) } - p.model.ScanRepo(p.repo) + err := p.model.ScanRepo(p.repo) + if err != nil { + invalidateRepo(p.repo, err) + return + } default: } @@ -190,7 +194,11 @@ func (p *puller) runRO() { if debugPull { dlog.Printf("%q: time for rescan", p.repo) } - p.model.ScanRepo(p.repo) + err := p.model.ScanRepo(p.repo) + if err != nil { + invalidateRepo(p.repo, err) + return + } } } |