diff options
Diffstat (limited to 'internal/builder/files.go')
-rw-r--r-- | internal/builder/files.go | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/internal/builder/files.go b/internal/builder/files.go index 20fedf9..a9046d7 100644 --- a/internal/builder/files.go +++ b/internal/builder/files.go @@ -32,6 +32,7 @@ func (mw *MultiWriteCloser) Close() error { lastErr = err } } + return lastErr } @@ -45,6 +46,7 @@ func openFileGz(filename string) (*gzip.Writer, error) { if err != nil { return nil, err } + return gzip.NewWriterLevel(f, gzipLevel) } @@ -54,6 +56,7 @@ func openFileBrotli(filename string) (*brotli.Writer, error) { if err != nil { return nil, err } + return brotli.NewWriterLevel(f, brotliLevel), nil } @@ -70,6 +73,7 @@ func multiOpenFile(filename string) (*MultiWriteCloser, error) { if err != nil { return nil, err } + return &MultiWriteCloser{ writers: []io.WriteCloser{r, gz, br}, multiWriter: io.MultiWriter(r, gz, br), @@ -79,34 +83,38 @@ func multiOpenFile(filename string) (*MultiWriteCloser, error) { func openFileAndVariants(filename string) (io.WriteCloser, error) { if compressFiles { return multiOpenFile(filename) - } else { - return openFileWrite(filename) } + + return openFileWrite(filename) } func copyRecursive(src, dst string) error { return filepath.WalkDir(src, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } rel, err := filepath.Rel(src, path) if err != nil { return err } if d.IsDir() { return mkdirp(dst, rel) - } else { - sf, err := os.Open(path) - if err != nil { - return err - } - defer sf.Close() - df, err := openFileAndVariants(filepath.Join(dst, rel)) - if err != nil { - return err - } - defer df.Close() - if _, err := io.Copy(df, sf); err != nil { - return err - } } + + sf, err := os.Open(path) + if err != nil { + return err + } + defer sf.Close() + df, err := openFileAndVariants(filepath.Join(dst, rel)) + if err != nil { + return err + } + defer df.Close() + if _, err := io.Copy(df, sf); err != nil { + return err + } + return nil }) } |