appendToFileFallback appends data by reading the existing file, then rewriting with the new data added. This is used as a fallback when O_APPEND is not supported by the underlying filesystem (e.g. FUSE-mounted cloud storage).
(fileName string, data []byte)
| 90 | // with the new data added. This is used as a fallback when O_APPEND is not |
| 91 | // supported by the underlying filesystem (e.g. FUSE-mounted cloud storage). |
| 92 | func appendToFileFallback(fileName string, data []byte) error { |
| 93 | existing, err := os.ReadFile(fileName) |
| 94 | if err != nil && !os.IsNotExist(err) { |
| 95 | return fmt.Errorf("failed to read existing summary file: %w", err) |
| 96 | } |
| 97 | existing = append(existing, data...) |
| 98 | return os.WriteFile(fileName, existing, 0644) |
| 99 | } |
| 100 | |
| 101 | func checkFilePath(filename string) error { |
| 102 | dirPath := filepath.Dir(filename) |