From 75a0661213faeba2db0e9f8de3f746fa1b1edf44 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 6 Mar 2020 11:34:12 -0800 Subject: [PATCH] data-usage: Fix the calculation of the next crawling round (#9096) This commit fixes a simple typo miscalculated the waiting time until the next round of data crawling to compute the data usage. --- cmd/data-usage.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/data-usage.go b/cmd/data-usage.go index e57ea483e..cea9ddeeb 100644 --- a/cmd/data-usage.go +++ b/cmd/data-usage.go @@ -74,15 +74,15 @@ func timeToCrawl(ctx context.Context, objAPI ObjectLayer) time.Duration { if dataUsageInfo.LastUpdate.IsZero() { return 1 * time.Second } - waitDuration := dataUsageInfo.LastUpdate.Sub(UTCNow()) - if waitDuration > dataUsageCrawlInterval { + timeSinceLastUpdate := UTCNow().Sub(dataUsageInfo.LastUpdate) + if timeSinceLastUpdate > dataUsageCrawlInterval { // Waited long enough start crawl in a 1 second return 1 * time.Second } // No crawling needed, ask the routine to wait until // the daily interval 12hrs - delta between last update // with current time. - return dataUsageCrawlInterval - waitDuration + return dataUsageCrawlInterval - timeSinceLastUpdate } var dataUsageLockTimeout = lifecycleLockTimeout