Skip to content

Commit

Permalink
fix(binaries): add engine version to db_gen for unpack (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Oct 26, 2021
1 parent d0a8a0b commit 95ca076
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions binaries/binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ var baseDirName = path.Join("prisma", "binaries")

// GlobalTempDir returns the path of where the engines live
// internally, this is the global temp dir
func GlobalTempDir() string {
func GlobalTempDir(version string) string {
temp := os.TempDir()
logger.Debug.Printf("temp dir: %s", temp)

return path.Join(temp, baseDirName, "engines", EngineVersion)
return path.Join(temp, baseDirName, "engines", version)
}

func GlobalUnpackDir() string {
return path.Join(GlobalTempDir(), "unpacked")
func GlobalUnpackDir(version string) string {
return path.Join(GlobalTempDir(version), "unpacked", "v2")
}

// GlobalCacheDir returns the path of where the CLI lives
Expand Down
6 changes: 4 additions & 2 deletions binaries/bindata/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"io"
"io/ioutil"
"os"

"github.com/prisma/prisma-client-go/binaries"
)

// TODO go fmt files after creation
Expand Down Expand Up @@ -59,9 +61,9 @@ import (
)
func init() {
unpack.Unpack(data, "%s")
unpack.Unpack(data, "%s", "%s")
}
`, name, constraints, pkg, name)
`, name, constraints, pkg, name, binaries.EngineVersion)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions binaries/unpack/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import (
// TODO check checksum after expanding file

// noinspection GoUnusedExportedFunction
func Unpack(data []byte, name string) {
func Unpack(data []byte, name string, version string) {
start := time.Now()

file := fmt.Sprintf("prisma-query-engine-%s", name)

// TODO check if dev env/dev binary in ~/.prisma
// TODO check if engine in local dir OR env var

tempDir := binaries.GlobalUnpackDir()
tempDir := binaries.GlobalUnpackDir(version)

dir := platform.CheckForExtension(platform.Name(), path.Join(tempDir, file))

Expand Down
2 changes: 1 addition & 1 deletion engine/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (e *QueryEngine) Disconnect() error {
func (e *QueryEngine) ensure() (string, error) {
ensureEngine := time.Now()

binariesPath := binaries.GlobalUnpackDir()
binariesPath := binaries.GlobalUnpackDir(binaries.EngineVersion)
// check for darwin/windows/linux first
binaryName := platform.CheckForExtension(platform.Name(), platform.Name())
exactBinaryName := platform.CheckForExtension(platform.Name(), platform.BinaryPlatformName())
Expand Down

0 comments on commit 95ca076

Please sign in to comment.