cache: Add detection code for old cache dirs

This commit is contained in:
Alexander Neumann
2017-11-20 21:32:25 +01:00
parent 06bd606d85
commit fa893ee477
3 changed files with 74 additions and 3 deletions

View File

@@ -353,13 +353,21 @@ func OpenRepository(opts GlobalOptions) (*repository.Repository, error) {
return s, nil
}
cache, err := cache.New(s.Config().ID, opts.CacheDir)
c, err := cache.New(s.Config().ID, opts.CacheDir)
if err != nil {
Warnf("unable to open cache: %v\n", err)
} else {
s.UseCache(cache)
return s, nil
}
oldCacheDirs, err := cache.Old(c.Base)
if err != nil {
Warnf("unable to find old cache directories: %v", err)
} else {
Verbosef("found %d old cache directories in %v remove them with 'restic cache --cleanup'\n",
len(oldCacheDirs), c.Base)
}
s.UseCache(c)
return s, nil
}