Allow disabling disk checking with 0 value for check interval

This commit is contained in:
Dane Everitt
2020-11-12 20:50:03 -08:00
parent ffb6bd72ef
commit 8081c83de4
3 changed files with 9 additions and 6 deletions

View File

@@ -97,6 +97,11 @@ func (fs *Filesystem) CachedUsage() int64 {
// This is primarily to avoid a bunch of I/O operations from piling up on the server, especially on servers
// with a large amount of files.
func (fs *Filesystem) DiskUsage(allowStaleValue bool) (int64, error) {
// A disk check interval of 0 means this functionality is completely disabled.
if fs.diskCheckInterval == 0 {
return 0, nil
}
if !fs.lastLookupTime.Get().After(time.Now().Add(time.Second * fs.diskCheckInterval * -1)) {
// If we are now allowing a stale response go ahead and perform the lookup and return the fresh
// value. This is a blocking operation to the calling process.