Glide now errors out if cache setup fails and cache is needed
diff --git a/action/cache.go b/action/cache.go index 9896f21..b2ee07a 100644 --- a/action/cache.go +++ b/action/cache.go
@@ -9,21 +9,15 @@ // CacheClear clears the Glide cache func CacheClear() { - l, err := cache.Location() - if err != nil { - msg.Die("Unable to clear the cache: %s", err) - } + l := cache.Location() - err = os.RemoveAll(l) + err := os.RemoveAll(l) if err != nil { msg.Die("Unable to clear the cache: %s", err) } cache.SetupReset() - err = cache.Setup() - if err != nil { - msg.Die("Unable to clear the cache: %s", err) - } + cache.Setup() msg.Info("Glide cache has been cleared.") }
diff --git a/action/config_wizard.go b/action/config_wizard.go index ea627b4..e941399 100644 --- a/action/config_wizard.go +++ b/action/config_wizard.go
@@ -37,10 +37,7 @@ conf := EnsureConfig() - err = cache.Setup() - if err != nil { - msg.Die("Problem setting up cache: %s", err) - } + cache.Setup() msg.Info("Looking for dependencies to make suggestions on") msg.Info("--> Scanning for dependencies not using version ranges") @@ -252,11 +249,7 @@ var createGitParseVersion = regexp.MustCompile(`(?m-s)(?:tags)/(\S+)$`) func wizardFindVersions(d *cfg.Dependency) { - l, err := cache.Location() - if err != nil { - msg.Debug("Problem detecting cache location: %s", err) - return - } + l := cache.Location() remote := d.Remote() key, err := cache.Key(remote)
diff --git a/cache/cache.go b/cache/cache.go index 5a8538d..21f4edd 100644 --- a/cache/cache.go +++ b/cache/cache.go
@@ -54,12 +54,12 @@ var setupMutex sync.Mutex // Setup creates the cache location. -func Setup() error { +func Setup() { setupMutex.Lock() defer setupMutex.Unlock() if isSetup { - return nil + return } msg.Debug("Setting up the cache directory") pths := []string{ @@ -71,12 +71,11 @@ for _, l := range pths { err := os.MkdirAll(filepath.Join(gpath.Home(), l), 0755) if err != nil { - return err + msg.Die("Cache directory unavailable: %s", err) } } isSetup = true - return nil } // SetupReset resets if setup has been completed. The next time setup is run @@ -86,11 +85,11 @@ } // Location returns the location of the cache. -func Location() (string, error) { +func Location() string { p := filepath.Join(gpath.Home(), "cache") - err := Setup() + Setup() - return p, err + return p } // scpSyntaxRe matches the SCP-like addresses used to access repos over SSH. @@ -153,10 +152,7 @@ if !Enabled { return ErrCacheDisabled } - location, err := Location() - if err != nil { - return err - } + location := Location() data.LastUpdate = time.Now().String() d, err := json.Marshal(data) if err != nil { @@ -185,10 +181,7 @@ if !Enabled { return &RepoInfo{}, ErrCacheDisabled } - location, err := Location() - if err != nil { - return &RepoInfo{}, err - } + location := Location() c := &RepoInfo{} p := filepath.Join(location, "info", key+".json") f, err := ioutil.ReadFile(p)
diff --git a/repo/vcs.go b/repo/vcs.go index e77e870..eacb1c0 100644 --- a/repo/vcs.go +++ b/repo/vcs.go
@@ -368,10 +368,7 @@ loc := dep.Remote() key, err := cp.Key(loc) if err == nil { - location, err := cp.Location() - if err != nil { - return err - } + location := cp.Location() d := filepath.Join(location, "src", key) repo, err := dep.GetRepo(d)