merge v0.23.0-rc changes

This commit is contained in:
Gani Georgiev
2024-09-29 19:23:19 +03:00
parent ad92992324
commit 844f18cac3
753 changed files with 85141 additions and 63396 deletions
+5 -7
View File
@@ -3,6 +3,7 @@ package archive
import (
"archive/zip"
"compress/flate"
"errors"
"io"
"io/fs"
"os"
@@ -23,24 +24,21 @@ func Create(src string, dest string, skipPaths ...string) error {
if err != nil {
return err
}
defer zf.Close()
zw := zip.NewWriter(zf)
defer zw.Close()
// register a custom Deflate compressor
zw.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
return flate.NewWriter(out, flate.BestSpeed)
})
if err := zipAddFS(zw, os.DirFS(src), skipPaths...); err != nil {
err = zipAddFS(zw, os.DirFS(src), skipPaths...)
if err != nil {
// try to cleanup at least the created zip file
os.Remove(dest)
return err
return errors.Join(err, zw.Close(), zf.Close(), os.Remove(dest))
}
return nil
return errors.Join(zw.Close(), zf.Close())
}
// note remove after similar method is added in the std lib (https://github.com/golang/go/issues/54898)