fix files path manipulation when separator isn't /
Alan Pearce alan@alanpearce.eu
Sun, 26 Jan 2025 13:39:41 +0100
1 files changed, 4 insertions(+), 5 deletions(-)
M internal/storage/files/writer.go → internal/storage/files/writer.go
@@ -6,7 +6,6 @@ "context" "io" "io/fs" "os" - "path" "path/filepath" "go.alanpearce.eu/x/log" @@ -75,7 +74,7 @@ return os.Open(filepath.Join(f.outputDirectory, filename)) } 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 @@ return nil } 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 @@ return nil } 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) 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") }