mirror of
https://github.com/kopia/kopia.git
synced 2026-10-26 16:18:53 -04:00
repo: moved creating cache directory from connect to first use (#450)
This commit is contained in:
1 parent
fff2b44e19
commit
e445dc5e61
2 files changed
+5
-4
No files matched your search
@@ -149,10 +149,6 @@ func setupCaching(ctx context.Context, configPath string, lc *LocalConfig, opt c
|
||||
|
||||
log(ctx).Debugf("Creating cache directory '%v' with max size %v", lc.Caching.CacheDirectory, lc.Caching.MaxCacheSizeBytes)
|
||||
|
||||
if err := os.MkdirAll(lc.Caching.CacheDirectory, 0700); err != nil {
|
||||
log(ctx).Warningf("unablet to create cache directory: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@@ -198,6 +199,10 @@ func readAndCacheFormatBlobBytes(ctx context.Context, st blob.Storage, cacheDire
|
||||
cachedFile := filepath.Join(cacheDirectory, "kopia.repository")
|
||||
|
||||
if cacheDirectory != "" {
|
||||
if err := os.MkdirAll(cacheDirectory, 0700); err != nil && !os.IsExist(err) {
|
||||
log(ctx).Warningf("unable to create cache directory: %v", err)
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(cachedFile) //nolint:gosec
|
||||
if err == nil {
|
||||
// read from cache.
|
||||
|
||||
Reference in new issue
Block a user