Skip to content

Commit 94d0f24

Browse files
thedadamsnjhale
andcommitted
fix: create the cache directory before writing last-checked file
If the cache directory is gone, then, currently, writing the last-checked file fails. This change ensures that the directory exists before trying to write the file. Co-authored-by: Nick Hale <[email protected]> Signed-off-by: Donnie Adams <[email protected]>
1 parent a356d09 commit 94d0f24

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/repos/get.go

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io/fs"
99
"os"
10+
"path"
1011
"path/filepath"
1112
"strings"
1213
"sync"
@@ -132,6 +133,10 @@ func (m *Manager) deferredSetUpCredentialHelpers(ctx context.Context, cliCfg *co
132133
return err
133134
}
134135

136+
if err := os.MkdirAll(path.Dir(m.credHelperDirs.LastCheckedFile), 0755); err != nil {
137+
return err
138+
}
139+
135140
// Update the last-checked file.
136141
if err := os.WriteFile(m.credHelperDirs.LastCheckedFile, []byte(now.Format(time.RFC3339)), 0644); err != nil {
137142
return err

0 commit comments

Comments
 (0)