MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / appendToFileFallback

Function appendToFileFallback

cli/cmd/summary.go:92–99  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
92func 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
101func checkFilePath(filename string) error {
102 dirPath := filepath.Dir(filename)

Callers 3

appendToFileFunction · 0.85

Calls 1

ErrorfMethod · 0.80