Skip to content

Commit 57afd91

Browse files
committed
Store cached config on absolute path if the relative doesn't work
1 parent bdc8416 commit 57afd91

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

framework/.changeset/v0.10.16.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Use volumes for user's home directory and `config` folder for the CL node
2+
- Store cached config on absolute path if the relative doesn't work

framework/config.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,17 @@ func Store[T any](cfg *T) error {
293293
if err != nil {
294294
return err
295295
}
296-
return os.WriteFile(filepath.Join(DefaultConfigDir, cachedOutName), d, 0600)
296+
297+
writePath := filepath.Join(DefaultConfigDir, cachedOutName)
298+
if _, err := os.Stat(writePath); err != nil {
299+
var absErr error
300+
writePath, absErr = filepath.Abs(cachedOutName)
301+
if absErr != nil {
302+
return fmt.Errorf("error getting absolute path for config file %s: %w", cachedOutName, absErr)
303+
}
304+
}
305+
306+
return os.WriteFile(writePath, d, 0600)
297307
}
298308

299309
// JSONStrDuration is JSON friendly duration that can be parsed from "1h2m0s" Go format

0 commit comments

Comments
 (0)