mirror of
https://github.com/restic/restic.git
synced 2025-08-15 00:57:27 +00:00
cache: Just try to open cache entry without calling stat first
Instead of first checking whether a file is in the repository cache and then opening it, we just can open the file. This saves one stat call. If the file is in the cache, everything is fine and otherwise the code follows its normal fallback path.
This commit is contained in:
2
internal/cache/file.go
vendored
2
internal/cache/file.go
vendored
@@ -43,7 +43,7 @@ type readCloser struct {
|
||||
// given handle. rd must be closed after use. If an error is returned, the
|
||||
// ReadCloser is nil.
|
||||
func (c *Cache) load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) {
|
||||
debug.Log("Load from cache: %v", h)
|
||||
debug.Log("Load(%v, %v, %v) from cache", h, length, offset)
|
||||
if !c.canBeCached(h.Type) {
|
||||
return nil, errors.New("cannot be cached")
|
||||
}
|
||||
|
Reference in New Issue
Block a user