mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
cache: Add PerformReadahead
This commit is contained in:
parent
809e218d20
commit
5436154f0d
2
internal/cache/backend.go
vendored
2
internal/cache/backend.go
vendored
@ -11,7 +11,7 @@ import (
|
|||||||
// Backend wraps a restic.Backend and adds a cache.
|
// Backend wraps a restic.Backend and adds a cache.
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
restic.Backend
|
restic.Backend
|
||||||
restic.Cache
|
*Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure cachedBackend implements restic.Backend
|
// ensure cachedBackend implements restic.Backend
|
||||||
|
12
internal/cache/cache.go
vendored
12
internal/cache/cache.go
vendored
@ -15,8 +15,9 @@ import (
|
|||||||
|
|
||||||
// Cache manages a local cache.
|
// Cache manages a local cache.
|
||||||
type Cache struct {
|
type Cache struct {
|
||||||
Path string
|
Path string
|
||||||
Base string
|
Base string
|
||||||
|
PerformReadahead func(restic.Handle) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const dirMode = 0700
|
const dirMode = 0700
|
||||||
@ -78,6 +79,9 @@ func writeCachedirTag(dir string) error {
|
|||||||
|
|
||||||
// New returns a new cache for the repo ID at basedir. If basedir is the empty
|
// New returns a new cache for the repo ID at basedir. If basedir is the empty
|
||||||
// string, the default cache location (according to the XDG standard) is used.
|
// string, the default cache location (according to the XDG standard) is used.
|
||||||
|
//
|
||||||
|
// For partial files, the complete file is loaded and stored in the cache when
|
||||||
|
// performReadahead returns true.
|
||||||
func New(id string, basedir string) (c *Cache, err error) {
|
func New(id string, basedir string) (c *Cache, err error) {
|
||||||
if basedir == "" {
|
if basedir == "" {
|
||||||
basedir, err = getXDGCacheDir()
|
basedir, err = getXDGCacheDir()
|
||||||
@ -124,6 +128,10 @@ func New(id string, basedir string) (c *Cache, err error) {
|
|||||||
c = &Cache{
|
c = &Cache{
|
||||||
Path: cachedir,
|
Path: cachedir,
|
||||||
Base: basedir,
|
Base: basedir,
|
||||||
|
PerformReadahead: func(restic.Handle) bool {
|
||||||
|
// do not perform readahead by default
|
||||||
|
return false
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user