fix: Do not cleanup range files in cache SaveMetadata when total hits are false (#10728)

master
Kaloyan Raev 4 years ago committed by GitHub
parent a982baff27
commit be7f67268d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      cmd/disk-cache-backend.go

@ -538,12 +538,15 @@ func (c *diskCache) saveMetadata(ctx context.Context, bucket, object string, met
}
m.Ranges[rs.String(actualSize)] = rsFileName
}
} else {
}
if rs == nil && !incHitsOnly {
// this is necessary cleanup of range files if entire object is cached.
for _, f := range m.Ranges {
removeAll(pathJoin(cachedPath, f))
if _, err := os.Stat(pathJoin(cachedPath, cacheDataFile)); err == nil {
for _, f := range m.Ranges {
removeAll(pathJoin(cachedPath, f))
}
m.Ranges = nil
}
m.Ranges = nil
}
m.Stat.Size = actualSize
m.Stat.ModTime = UTCNow()

Loading…
Cancel
Save