repo: moved creating cache directory from connect to first use (#450)

This commit is contained in:
Jarek Kowalski authored and GitHub committed 2020-05-22 10:08:48 -07:00
1 parent fff2b44e19
commit e445dc5e61
2 files changed
+5 -4

No files matched your search

-4
View File
@@ -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
View File
@@ -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.