Skip to content

Commit

Permalink
fix: mkdirall dir when new file cachego
Browse files Browse the repository at this point in the history
  • Loading branch information
rfyiamcool committed May 7, 2023
1 parent 215d98a commit e7163a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
Expand All @@ -32,6 +31,7 @@ const perm = 0o666

// New creates an instance of File cache
func New(dir string) cachego.Cache {
_ = os.MkdirAll(dir, os.ModePerm)
return &file{dir: dir}
}

Expand Down Expand Up @@ -100,7 +100,7 @@ func (f *file) Fetch(key string) (string, error) {

if f.isExpired(content) {
_ = f.Delete(key)
return "", errors.New("cache expired")
return "", cachego.ErrCacheExpired
}

return content.Data, nil
Expand Down

0 comments on commit e7163a6

Please sign in to comment.