Skip to content

Commit

Permalink
chore: Update extract logic for using newer 7zz/7zzs/7zr.exe binaries (
Browse files Browse the repository at this point in the history
…#139)

* Conditionally adds `-snld` flag when detecting not `7za` binary to allow extracting relative links outside of host dir (to maintain backward compatibility with legacy 7za versus newer 7zz/7zzs/7zr.exe)
  • Loading branch information
mmaietta authored Sep 24, 2024
1 parent 28db936 commit 128737e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-pianos-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-bin": patch
---

chore: Update extract logic for using newer 7zz/7zzs/7zr.exe binaries
12 changes: 10 additions & 2 deletions pkg/download/artifactDownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/develar/app-builder/pkg/log"
"github.com/develar/app-builder/pkg/util"
"github.com/develar/errors"
"github.com/develar/go-fs-util"
fsutil "github.com/develar/go-fs-util"
"github.com/mitchellh/go-homedir"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -115,7 +115,15 @@ func DownloadArtifact(dirName string, url string, checksum string) (string, erro
return "", err
}
} else {
command := exec.Command(util.Get7zPath(), "x", "-bd", archiveName, "-o"+tempUnpackDir)
path7zX := util.Get7zPath()
var args []string
args = append(args, "x")
if !strings.HasSuffix(path7zX, "7za") {
// -snld flag for https://sourceforge.net/p/sevenzip/bugs/2356/ to maintain backward compatibility between versions of 7za (old) and 7zz/7zzs/7zr.exe (new)
args = append(args, "-snld")
}
args = append(args, "-bd", archiveName, "-o"+tempUnpackDir)
command := exec.Command(path7zX, args...)
command.Dir = cacheDir
_, err := util.Execute(command)
if err != nil {
Expand Down

0 comments on commit 128737e

Please sign in to comment.