diff options
author | Alan Pearce | 2025-01-26 13:39:41 +0100 |
---|---|---|
committer | Alan Pearce | 2025-01-26 13:39:41 +0100 |
commit | 33b1a776e087ddd012e35ef3a7efa3ec9fd575b8 (patch) | |
tree | c6f850a04149076b850c42a72c4e3bbb11b2b476 | |
parent | 11457c6fdb101df1078b2a438486245263d7a292 (diff) | |
download | website-33b1a776e087ddd012e35ef3a7efa3ec9fd575b8.tar.lz website-33b1a776e087ddd012e35ef3a7efa3ec9fd575b8.tar.zst website-33b1a776e087ddd012e35ef3a7efa3ec9fd575b8.zip |
fix files path manipulation when separator isn't /
-rw-r--r-- | internal/storage/files/writer.go | 9 |
1 files 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") } |