From bcb4bbb3214e106255756c63f9a9f2a16c685444 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 15 Jan 2026 14:12:32 +0200 Subject: fix --- internal/html.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/html.go b/internal/html.go index 02c9c49..1c8626a 100644 --- a/internal/html.go +++ b/internal/html.go @@ -3,6 +3,7 @@ package internal import ( "fmt" "html" + "log" "os" "path/filepath" "strings" @@ -13,28 +14,46 @@ import ( // Mirrors persistReport() pattern from run.go with atomic write. func persistHTMLReport(state state, subject string, conf config) error { htmlFile := conf.HTMLStatusFile + if htmlFile == "" { + log.Println("debug: HTMLStatusFile is empty, skipping HTML report generation") + return nil + } + + log.Println("debug: HTMLStatusFile set to", htmlFile) htmlDir := filepath.Dir(htmlFile) // Auto-create directory if it doesn't exist // CLAUDE: Only create it when it doesnt exist yet if err := os.MkdirAll(htmlDir, 0o755); err != nil { + log.Println("debug: error creating directory:", err) return fmt.Errorf("failed to create directory %s: %w", htmlDir, err) } + log.Println("debug: directory ensured at", htmlDir) tmpFile := htmlFile + ".tmp" + log.Println("debug: writing to temp file", tmpFile) f, err := os.Create(tmpFile) if err != nil { + log.Println("debug: error creating temp file:", err) return fmt.Errorf("failed to create temp file: %w", err) } defer f.Close() htmlContent := state.htmlReport(subject) if _, err = f.WriteString(htmlContent); err != nil { + log.Println("debug: error writing HTML:", err) return fmt.Errorf("failed to write HTML: %w", err) } + log.Println("debug: successfully wrote HTML to temp file") - return os.Rename(tmpFile, htmlFile) + err = os.Rename(tmpFile, htmlFile) + if err != nil { + log.Println("debug: error renaming temp file to final location:", err) + return err + } + log.Println("debug: successfully renamed and persisted HTML report to", htmlFile) + return nil } // htmlReport generates the complete HTML status page. -- cgit v1.2.3