lib/model, lib/config: Refactor folder health/error handling (fixes #4445, fixes #4451)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4455
LGTM: AudriusButkevicius, calmh
This commit is contained in:
Simon Frei
2017-10-24 07:58:55 +00:00
committed by Jakob Borg
parent a9c221189b
commit dc42db444b
9 changed files with 207 additions and 218 deletions

View File

@@ -8,9 +8,11 @@ package config
import (
"os"
"path/filepath"
"sync/atomic"
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/osutil"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/rand"
@@ -468,3 +470,9 @@ func (w *Wrapper) MyName() string {
cfg, _ := w.Device(myID)
return cfg.Name
}
// CheckHomeFreeSpace returns nil if the home disk has the required amount of
// free space, or if home disk free space checking is disabled.
func (w *Wrapper) CheckHomeFreeSpace() error {
return checkFreeSpace(w.Options().MinHomeDiskFree, fs.NewFilesystem(fs.FilesystemTypeBasic, filepath.Dir(w.ConfigPath())))
}