v0.2.2 fixes: split only text sources, report a mode change once, don't block on open
Test / test (push) Canceled after 0s
Test / test (push) Canceled after 0s
This commit is contained in:
1 parent
2a47be454d
commit
9b4d98672d
19 files changed
+365
-59
No files matched your search
@@ -68,7 +68,7 @@ func readConfigFile(ctx context.Context, path string, opts fileSettings) (*fileS
|
||||
if !info.Mode().IsRegular() {
|
||||
return nil, wrapError(ErrFileAccess, fmt.Errorf("config must be a regular file"))
|
||||
}
|
||||
file, err := os.Open(path)
|
||||
file, err := openConfig(path)
|
||||
if err != nil {
|
||||
return nil, wrapError(ErrFileAccess, err)
|
||||
}
|
||||
@@ -113,6 +113,13 @@ func readConfigFile(ctx context.Context, path string, opts fileSettings) (*fileS
|
||||
return &fileSnapshot{data, after, sha256.Sum256(data)}, nil
|
||||
}
|
||||
|
||||
// openConfig opens without blocking: a FIFO swapped in after the Stat cannot
|
||||
// hang open(2), and a regular-looking file whose reads block (/proc/kmsg)
|
||||
// fails its read instead
|
||||
func openConfig(path string) (*os.File, error) {
|
||||
return os.OpenFile(path, os.O_RDONLY|openNonBlock, 0)
|
||||
}
|
||||
|
||||
func parseFile(snapshot *fileSnapshot) (map[string]any, []string, error) {
|
||||
root, err := toml.NewParser(snapshot.data).Parse()
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user