Don't verify free space for files when folder MinDiskFreePct==0 (fixes #2600)

This commit is contained in:
Jakob Borg 2015-12-19 13:57:44 +01:00
parent 2cdfa59fbe
commit 03935b2d64

View File

@ -92,6 +92,7 @@ type rwFolder struct {
sleep time.Duration
pause time.Duration
allowSparse bool
checkFreeSpace bool
stop chan struct{}
queue *jobQueue
@ -127,6 +128,7 @@ func newRWFolder(m *Model, shortID uint64, cfg config.FolderConfiguration) *rwFo
order: cfg.Order,
maxConflicts: cfg.MaxConflicts,
allowSparse: !cfg.DisableSparseFiles,
checkFreeSpace: cfg.MinDiskFreePct != 0,
stop: make(chan struct{}),
queue: newJobQueue(),
@ -967,11 +969,13 @@ func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocks
}
}
if p.checkFreeSpace {
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.folder, 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,