Skip to content

Commit

Permalink
cache: fixup pogreb db permissions (#1317)
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed May 17, 2024
1 parent e7ca8e3 commit 3a4d9e1
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions pkg/cache/pogrebv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func newPogrebV1Backend(baseDir string) *pogrebV1Backend {
}

const (
pogrebV1CacheModeDir = 0750
pogrebV1CacheModeFile = 0640
pogrebV1CacheModeDir = 0770
pogrebV1CacheModeFile = 0660

pograbV1CacheDir = "pogreb.v1"
pogrebDigestFile = pograbV1CacheDir + "/digest"
Expand Down Expand Up @@ -86,7 +86,24 @@ func (q *pogrebV1Backend) Close() error {
if q.db == nil {
return nil
}
return q.db.Close()
if err := q.db.Close(); err != nil {
return err
}

// Recursively fixup permissions on the DB directory.
return filepath.Walk(filepath.Join(q.baseDir, pogrebDbDir), func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
switch info.Mode().Type() {
case os.ModeDir:
return os.Chmod(path, pogrebV1CacheModeDir)
case 0:
return os.Chmod(path, pogrebV1CacheModeFile)
default:
return nil
}
})
}

func (q *pogrebV1Backend) GetPackageIndex(_ context.Context) (packageIndex, error) {
Expand Down

0 comments on commit 3a4d9e1

Please sign in to comment.