From 3e5d1008128b32a73ee1f71aabd938efab3fdf0e Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Fri, 4 Aug 2023 21:22:23 -0700 Subject: [PATCH] fix: Fix zip file path on Windows platform --- internal/archive/zip/zip.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/archive/zip/zip.go b/internal/archive/zip/zip.go index 5ca82efe1..e0db52f43 100644 --- a/internal/archive/zip/zip.go +++ b/internal/archive/zip/zip.go @@ -40,6 +40,10 @@ func New(f io.Writer, matcher sauceignore.Matcher) (Writer, error) { // Add adds the file at src to the destination dst in the archive and returns a count of // the files added to the archive, as well the length of the longest path. +// The added file names should not contain any backslashes according to the specification outlined in +// https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT. +// It's essential to adhere to this specification to ensure compatibility and +// proper functioning of the files across different systems and platforms. func (w *Writer) Add(src, dst string) (count int, length int, err error) { finfo, err := os.Stat(src) if err != nil { @@ -57,7 +61,7 @@ func (w *Writer) Add(src, dst string) (count int, length int, err error) { // The trailing slash denotes a directory entry. target = fmt.Sprintf("%s/", target) } - fileWriter, err := w.W.Create(target) + fileWriter, err := w.W.Create(filepath.ToSlash(target)) if err != nil { return 0, 0, err }