Keep recovery handoffs available after publication cancellation
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/mod/modfile"
|
||||
|
||||
@@ -17,6 +19,30 @@ import (
|
||||
const releaseKitModule = "go.maximumdirect.net/releasekit"
|
||||
const releaseKitCommand = releaseKitModule + "/cmd/releasekit"
|
||||
|
||||
// TemporaryExecutable recognizes executables in Go's temporary build layout,
|
||||
// <work parent>/go-build<nonce>/b<action>/exe/<name>. Those paths disappear when
|
||||
// the Go driver finishes and cannot provide a later native-command fallback.
|
||||
func TemporaryExecutable(path string) bool {
|
||||
exeDir := filepath.Dir(path)
|
||||
if filepath.Base(exeDir) != "exe" {
|
||||
return false
|
||||
}
|
||||
actionDir := filepath.Dir(exeDir)
|
||||
action, ok := strings.CutPrefix(filepath.Base(actionDir), "b")
|
||||
if !ok || action == "" {
|
||||
return false
|
||||
}
|
||||
if _, err := strconv.ParseUint(action, 10, 64); err != nil {
|
||||
return false
|
||||
}
|
||||
nonce, ok := strings.CutPrefix(filepath.Base(filepath.Dir(actionDir)), "go-build")
|
||||
if !ok || nonce == "" {
|
||||
return false
|
||||
}
|
||||
_, err := strconv.ParseUint(nonce, 10, 64)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// RecoveryTool returns module-selected Go arguments for a later invocation.
|
||||
// An empty result means this module does not select ReleaseKit. API-only modules
|
||||
// receive a private module root that outlives launcher-owned bootstraps.
|
||||
|
||||
Reference in New Issue
Block a user