summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2015-09-12 23:00:43 +0200
committerJakob Borg <jakob@nym.se>2015-09-13 11:44:54 +0200
commitb98a8bafb3ade57bdb8536c98cdce5d94ba62148 (patch)
tree50a7d976504bb313ef2080dad3d276c4fd31e755
parent4b5c44b61c9b8b90ec9413b7cb461019a261a50d (diff)
Don't require free disk space when we might only update metadata
Instead, make sure we do the check as part of CheckFolderHealth before pulling, and individually per file to try to not run out of space at that stage. (The latter is far from fool proof as we may pull lots of stuff in parallell, but it's worth a try.)
-rw-r--r--lib/model/rwfolder.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/model/rwfolder.go b/lib/model/rwfolder.go
index 5c691f9f92..bfd83e6c25 100644
--- a/lib/model/rwfolder.go
+++ b/lib/model/rwfolder.go
@@ -212,6 +212,12 @@ func (p *rwFolder) Serve() {
continue
}
+ if err := p.model.CheckFolderHealth(p.folder); err != nil {
+ l.Infoln("Skipping folder", p.folder, "pull due to folder error:", err)
+ p.pullTimer.Reset(nextPullIntv)
+ continue
+ }
+
p.model.fmut.RLock()
curIgnores := p.model.folderIgnores[p.folder]
p.model.fmut.RUnlock()
@@ -451,7 +457,6 @@ func (p *rwFolder) pullerIteration(ignores *ignore.Matcher) int {
// !!!
changed := 0
- pullFileSize := int64(0)
fileDeletions := map[string]protocol.FileInfo{}
dirDeletions := []protocol.FileInfo{}
@@ -500,7 +505,6 @@ func (p *rwFolder) pullerIteration(ignores *ignore.Matcher) int {
default:
// A new or changed file or symlink. This is the only case where we
// do stuff concurrently in the background
- pullFileSize += file.Size()
p.queue.Push(file.Name, file.Size(), file.Modified)
}
@@ -508,16 +512,6 @@ func (p *rwFolder) pullerIteration(ignores *ignore.Matcher) int {
return true
})
- // Check if we are able to store all files on disk. Only perform this
- // check if there is a minimum free space threshold set on the folder.
- folderCfg := p.model.cfg.Folders()[p.folder]
- if folderCfg.MinDiskFreePct > 0 && pullFileSize > 0 {
- if free, err := osutil.DiskFreeBytes(folderCfg.Path()); err == nil && free < pullFileSize {
- l.Warnf(`Folder "%s": insufficient disk space available to pull %d files (%.2f MiB)`, p.folder, changed, float64(pullFileSize)/1024/1024)
- return 0
- }
- }
-
// Reorder the file queue according to configuration
switch p.order {
@@ -970,6 +964,12 @@ func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocks
return
}
+ if free, err := osutil.DiskFreeBytes(p.dir); err == nil && free < file.Size() {
+ l.Warnf(`Folder "%s": insufficient disk space in %s for %s: have %.2f MiB, need %.2f MiB`, p.dir, file.Name, float64(free)/1024/1024, float64(file.Size())/1024/1024)
+ p.newError(file.Name, errors.New("insufficient space"))
+ return
+ }
+
events.Default.Log(events.ItemStarted, map[string]string{
"folder": p.folder,
"item": file.Name,