Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
Signed-off-by: jiefenghuang <[email protected]>
  • Loading branch information
jiefenghuang committed Sep 29, 2024
1 parent 68f6ff2 commit 89fcbd9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/chunk/disk_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,17 +496,12 @@ func (cache *cacheStore) createDir(dir string) {
mode := cache.mode | (readmode >> 2) | (readmode >> 1)
var st os.FileInfo
var err error
dir = filepath.Clean(dir)
if st, err = os.Stat(dir); os.IsNotExist(err) {
if len(dir) > 1 && strings.HasSuffix(dir, string(filepath.Separator)) {
dir = dir[:len(dir)-1] // CacheManager appends "/" to dir, remove it so that `filepath.Dir` returns the parent dir
}
if filepath.Dir(dir) != dir {
cache.createDir(filepath.Dir(dir))
}
if err = os.Mkdir(dir, mode); err != nil {
logger.Warnf("create cache dir %s: %s", dir, err)
return err
}
_ = os.Mkdir(dir, mode)
// umask may remove some permissions
return os.Chmod(dir, mode)
} else if strings.HasPrefix(dir, cache.dir) && err == nil && st.Mode().Perm() != mode.Perm() { // check permission only
Expand Down

0 comments on commit 89fcbd9

Please sign in to comment.