Skip to content

Commit

Permalink
Merge pull request #105 from cloudfoundry/tar-path-fix
Browse files Browse the repository at this point in the history
fix issue with tar paths when compressing on windows
  • Loading branch information
selzoc authored Nov 19, 2024
2 parents 286b381 + 10159b4 commit 314364a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fileutil/tarball_compressor.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package fileutil

import (
"os"
"io"
"fmt"
"io"
"io/fs"
"strings"
"os"
"path/filepath"
"runtime"
"strings"

"archive/tar"

"github.com/klauspost/pgzip"

bosherr "github.com/cloudfoundry/bosh-utils/errors"
Expand Down Expand Up @@ -68,10 +70,10 @@ func (c tarballCompressor) CompressSpecificFilesInDir(dir string, files []string
return bosherr.WrapError(err, "Resovling relative tar path")
}

if fi.IsDir() {
relPath = relPath + "/"
header.Name = relPath
if runtime.GOOS == "windows" {
header.Name = strings.ReplaceAll(relPath, "\\", "/")
}
header.Name = filepath.FromSlash(relPath)

if err := tw.WriteHeader(header); err != nil {
return bosherr.WrapError(err, "Writing tar header")
Expand Down

0 comments on commit 314364a

Please sign in to comment.