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

@ -79,19 +79,20 @@ type rwFolder struct {
progressEmitter *ProgressEmitter progressEmitter *ProgressEmitter
virtualMtimeRepo *db.VirtualMtimeRepo virtualMtimeRepo *db.VirtualMtimeRepo
folder string folder string
dir string dir string
scanIntv time.Duration scanIntv time.Duration
versioner versioner.Versioner versioner versioner.Versioner
ignorePerms bool ignorePerms bool
copiers int copiers int
pullers int pullers int
shortID uint64 shortID uint64
order config.PullOrder order config.PullOrder
maxConflicts int maxConflicts int
sleep time.Duration sleep time.Duration
pause time.Duration pause time.Duration
allowSparse bool allowSparse bool
checkFreeSpace bool
stop chan struct{} stop chan struct{}
queue *jobQueue queue *jobQueue
@ -117,16 +118,17 @@ func newRWFolder(m *Model, shortID uint64, cfg config.FolderConfiguration) *rwFo
progressEmitter: m.progressEmitter, progressEmitter: m.progressEmitter,
virtualMtimeRepo: db.NewVirtualMtimeRepo(m.db, cfg.ID), virtualMtimeRepo: db.NewVirtualMtimeRepo(m.db, cfg.ID),
folder: cfg.ID, folder: cfg.ID,
dir: cfg.Path(), dir: cfg.Path(),
scanIntv: time.Duration(cfg.RescanIntervalS) * time.Second, scanIntv: time.Duration(cfg.RescanIntervalS) * time.Second,
ignorePerms: cfg.IgnorePerms, ignorePerms: cfg.IgnorePerms,
copiers: cfg.Copiers, copiers: cfg.Copiers,
pullers: cfg.Pullers, pullers: cfg.Pullers,
shortID: shortID, shortID: shortID,
order: cfg.Order, order: cfg.Order,
maxConflicts: cfg.MaxConflicts, maxConflicts: cfg.MaxConflicts,
allowSparse: !cfg.DisableSparseFiles, allowSparse: !cfg.DisableSparseFiles,
checkFreeSpace: cfg.MinDiskFreePct != 0,
stop: make(chan struct{}), stop: make(chan struct{}),
queue: newJobQueue(), queue: newJobQueue(),
@ -967,10 +969,12 @@ func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocks
} }
} }
if free, err := osutil.DiskFreeBytes(p.dir); err == nil && free < file.Size() { if p.checkFreeSpace {
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) if free, err := osutil.DiskFreeBytes(p.dir); err == nil && free < file.Size() {
p.newError(file.Name, errors.New("insufficient space")) 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)
return p.newError(file.Name, errors.New("insufficient space"))
return
}
} }
events.Default.Log(events.ItemStarted, map[string]string{ events.Default.Log(events.ItemStarted, map[string]string{