Skip to content

Commit

Permalink
fix: ensure cache directory always exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pd93 committed Aug 29, 2023
1 parent 283154f commit 2782c6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion taskfile/read/node_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (node *HTTPNode) Read() (*taskfile.Taskfile, error) {
func (node *HTTPNode) getCachePath() string {
h := sha256.New()
h.Write([]byte(node.URL.String()))
return filepath.Join(node.TempDir, base64.URLEncoding.EncodeToString(h.Sum(nil)))
return filepath.Join(node.TempDir, "remote", base64.URLEncoding.EncodeToString(h.Sum(nil)))
}

func (node *HTTPNode) getHashFromCache() (string, error) {
Expand All @@ -123,5 +123,8 @@ func (node *HTTPNode) getHashFromCache() (string, error) {

func (node *HTTPNode) toCache(hash []byte) error {
path := node.getCachePath()
if err := os.MkdirAll(path, 0o755); err != nil {
return err
}
return os.WriteFile(path, hash, 0o644)
}

0 comments on commit 2782c6e

Please sign in to comment.