Documentation ¶
Index ¶
- Constants
- func All(basedir string) (dirs []os.FileInfo, err error)
- func DefaultDir() (cachedir string, err error)
- func IsOld(t time.Time, maxAge time.Duration) bool
- func Old(basedir string) ([]os.FileInfo, error)
- func OlderThan(basedir string, max time.Duration) ([]os.FileInfo, error)
- type Backend
- func (b *Backend) IsNotExist(err error) bool
- func (b *Backend) Load(ctx context.Context, h restic.Handle, length int, offset int64, ...) error
- func (b *Backend) Remove(ctx context.Context, h restic.Handle) error
- func (b *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error
- func (b *Backend) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error)
- type Cache
- func (c *Cache) BaseDir() string
- func (c *Cache) Clear(t restic.FileType, valid restic.IDSet) error
- func (c *Cache) Has(h restic.Handle) bool
- func (c *Cache) IsNotExist(err error) bool
- func (c *Cache) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error)
- func (c *Cache) Remove(h restic.Handle) error
- func (c *Cache) Save(h restic.Handle, rd io.Reader) error
- func (c *Cache) SaveWriter(h restic.Handle) (io.WriteCloser, error)
- func (c *Cache) Wrap(be restic.Backend) restic.Backend
Constants ¶
const MaxCacheAge = 30 * 24 * time.Hour
MaxCacheAge is the default age (30 days) after which cache directories are considered old.
Variables ¶
This section is empty.
Functions ¶
func DefaultDir ¶ added in v0.8.1
DefaultDir returns the default cache directory for the current OS.
Types ¶
type Backend ¶
Backend wraps a restic.Backend and adds a cache.
func (*Backend) IsNotExist ¶
IsNotExist returns true if the error is caused by a non-existing file.
func (*Backend) Load ¶
func (b *Backend) Load(ctx context.Context, h restic.Handle, length int, offset int64, consumer func(rd io.Reader) error) error
Load loads a file from the cache or the backend.
func (*Backend) Remove ¶
Remove deletes a file from the backend and the cache if it has been cached.
type Cache ¶
Cache manages a local cache.
func New ¶
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.
For partial files, the complete file is loaded and stored in the cache when performReadahead returns true.
func TestNewCache ¶
TestNewCache returns a cache in a temporary directory which is removed when cleanup is called.
func (*Cache) Clear ¶
Clear removes all files of type t from the cache that are not contained in the set valid.
func (*Cache) IsNotExist ¶
IsNotExist returns true if the error was caused by a non-existing file.
func (*Cache) Load ¶
Load returns a reader that yields the contents of the file with the given handle. rd must be closed after use. If an error is returned, the ReadCloser is nil.
func (*Cache) SaveWriter ¶
SaveWriter returns a writer for the cache object h. It must be closed after writing is finished.