From 53e08ce7f93163e68f64bbc6b5f9abd80995749e Mon Sep 17 00:00:00 2001 From: EnumDev Date: Sat, 4 Oct 2025 09:43:44 +0300 Subject: [PATCH] Ensure package downloads stay in the temporary directory --- src/bpmlib/compilation.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bpmlib/compilation.go b/src/bpmlib/compilation.go index dd73f9d..695ce1d 100644 --- a/src/bpmlib/compilation.go +++ b/src/bpmlib/compilation.go @@ -357,8 +357,8 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error { switch download.Type { case "", "file": filepath := path.Join(tempDirectory, path.Base(downloadUrl)) - if download.Filepath != "" { - filepath = download.Filepath + if download.Filepath != "" && download.Filepath[0] != '/' { + filepath = path.Join(tempDirectory, download.Filepath) } err := downloadFile(downloadUrl, filepath, 0644) @@ -389,6 +389,7 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error { if !download.NoExtract && (strings.Contains(filepath, ".tar") || strings.HasSuffix(filepath, ".tgz")) { cmd := exec.Command("tar", "xvf", filepath, "--strip-components="+strconv.Itoa(download.ExtractStripComponents)) + cmd.Dir = tempDirectory if download.ExtractToBPMSource { cmd.Args = append(cmd.Args, "-C", path.Join(tempDirectory, "source")) } @@ -439,6 +440,7 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error { } cmd := exec.Command("git", "clone", "--depth=1", downloadUrl) + cmd.Dir = tempDirectory if gitBranch != "" { cmd.Args = slices.Insert(cmd.Args, len(cmd.Args)-1, "--branch="+gitBranch) }