TMP directory crud
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Colin 2024-06-12 21:19:21 -04:00
parent 4a22420311
commit c2f6cd46f2
1 changed files with 14 additions and 5 deletions

19
main.go
View File

@ -233,14 +233,23 @@ func filterDiffOutput(diffOutput, cname string, ignores []string) (string, error
}
func writeToFile(filename, content string) error {
file, err := os.Create(filename)
tempFile, err := os.CreateTemp("", "filtered_output")
if err != nil {
return err
return fmt.Errorf("error creating temporary file: %s", err)
}
defer file.Close()
defer os.Remove(tempFile.Name()) // Ensure the temporary file is removed
_, err = file.WriteString(content)
return err
_, err = tempFile.WriteString(content)
if err != nil {
return fmt.Errorf("error writing to temporary file: %s", err)
}
err = copyFile(tempFile.Name(), filename)
if err != nil {
return fmt.Errorf("error copying temporary file to final destination: %s", err)
}
return nil
}
func sendNotification(content string) error {