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.
master
Anis Elleuch 5 years ago committed by GitHub
parent a1c7c9ea73
commit 75a0661213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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

Loading…
Cancel
Save