lib/config: Add context to the home disk out of space error (#5241)

This commit is contained in:
Simon Frei 2018-10-05 08:21:39 +02:00 committed by Jakob Borg
parent 86a22b8086
commit 714a47ffb0
1 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,7 @@
package config
import (
"fmt"
"os"
"path/filepath"
"sync/atomic"
@ -499,8 +500,11 @@ func (w *Wrapper) AddOrUpdatePendingFolder(id, label string, device protocol.Dev
// 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 {
if usage, err := fs.NewFilesystem(fs.FilesystemTypeBasic, filepath.Dir(w.ConfigPath())).Usage("."); err == nil {
return checkFreeSpace(w.Options().MinHomeDiskFree, usage)
path := filepath.Dir(w.ConfigPath())
if usage, err := fs.NewFilesystem(fs.FilesystemTypeBasic, path).Usage("."); err == nil {
if err = checkFreeSpace(w.Options().MinHomeDiskFree, usage); err != nil {
return fmt.Errorf("insufficient space on home disk (%v): %v", path, err)
}
}
return nil
}