summaryrefslogtreecommitdiff
path: root/internal/html.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-01-15 14:12:32 +0200
committerPaul Buetow <paul@buetow.org>2026-01-15 14:12:32 +0200
commitbcb4bbb3214e106255756c63f9a9f2a16c685444 (patch)
tree16261f08fd9201cd1d6b1bd65cbe6d57f97d0a26 /internal/html.go
parent11f4b5dfd3607106496c9d81693dd00988f3e3fc (diff)
fix
Diffstat (limited to 'internal/html.go')
-rw-r--r--internal/html.go21
1 files changed, 20 insertions, 1 deletions
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.