From 33b1a776e087ddd012e35ef3a7efa3ec9fd575b8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 26 Jan 2025 13:39:41 +0100 Subject: fix files path manipulation when separator isn't / --- internal/storage/files/writer.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/storage/files/writer.go b/internal/storage/files/writer.go index 6f10fe7..9831435 100644 --- a/internal/storage/files/writer.go +++ b/internal/storage/files/writer.go @@ -6,7 +6,6 @@ import ( "io" "io/fs" "os" - "path" "path/filepath" "go.alanpearce.eu/x/log" @@ -75,7 +74,7 @@ func (f *Files) Open(filename string) (io.ReadCloser, error) { } func (f *Files) OutputToFile(output io.Reader, filename string) error { - fn := path.Join(f.outputDirectory, filename) + fn := filepath.Join(f.outputDirectory, filename) if err := f.mkdirp(filepath.Dir(filename)); err != nil { return err } @@ -94,7 +93,7 @@ func (f *Files) OutputToFile(output io.Reader, filename string) error { } func (f *Files) RenderToFile(component templ.Component, filename string) error { - fn := path.Join(f.outputDirectory, filename) + fn := filepath.Join(f.outputDirectory, filename) if err := f.mkdirp(filepath.Dir(filename)); err != nil { return err } @@ -113,7 +112,7 @@ func (f *Files) RenderToFile(component templ.Component, filename string) error { } func (f *Files) WriterToFile(writer io.WriterTo, filename string) error { - fn := path.Join(f.outputDirectory, filename) + fn := filepath.Join(f.outputDirectory, filename) if err := f.mkdirp(filepath.Dir(filename)); err != nil { return err } @@ -206,7 +205,7 @@ func (f *Files) openFileAndVariants(filename string) (io.WriteCloser, error) { func (f *Files) mkdirp(dir string) error { f.log.Debug("creating directory", "dir", dir) - err := os.MkdirAll(path.Join(f.outputDirectory, dir), 0755) + err := os.MkdirAll(filepath.Join(f.outputDirectory, dir), 0755) return errors.WithMessage(err, "could not create directory") } -- cgit 1.4.1