Skip to content

Commit 5bc51f9

Browse files
committed
fix legacy absolute problem
1 parent 61d668a commit 5bc51f9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/options/base.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ func readFileFromLocal(base []string, sub string, elems ...string) ([]byte, erro
100100
copy(localPathElems[2:], elems)
101101

102102
for _, dir := range base {
103+
if !filepath.IsAbs(dir) {
104+
// FIXME: the old behavior (CustomPath or StaticRootPath might not be absolute), not ideal, just keep the same as before
105+
var err error
106+
dir, err = filepath.Abs(dir)
107+
if err != nil {
108+
return nil, fmt.Errorf("unable to get absolute path for %q. %w", dir, err)
109+
}
110+
}
103111
localPathElems[0] = dir
104112
localPath := util.SafeFilePathAbs(localPathElems...)
105113
data, err := os.ReadFile(localPath)
@@ -109,5 +117,5 @@ func readFileFromLocal(base []string, sub string, elems ...string) ([]byte, erro
109117
log.Error("Unable to read file %q. Error: %v", localPath, err)
110118
}
111119
}
112-
return nil, fmt.Errorf("local file does not exist: %v", elems)
120+
return nil, os.ErrNotExist
113121
}

0 commit comments

Comments
 (0)