mirror of
https://github.com/black-ant/Ant-Browser.git
synced 2026-07-14 18:48:55 +08:00
channel: master
version: 1.2.0
source-ref: D:\code\open_source\ant-chrome master
source-commit: f3d7ec5
merged-public-base: 3d264eb
58 lines
978 B
Go
58 lines
978 B
Go
package automation
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type runtimeInstallWorkspace struct {
|
|
TempRoot string
|
|
StagingDir string
|
|
}
|
|
|
|
func (w runtimeInstallWorkspace) cleanup() {
|
|
_ = removeRuntimeInstallWorkspace(w.StagingDir)
|
|
}
|
|
|
|
func ensureRuntimeInstallContext(ctx context.Context) context.Context {
|
|
if ctx == nil {
|
|
return context.Background()
|
|
}
|
|
return ctx
|
|
}
|
|
|
|
func (m *Manager) beginRuntimeInstall(flagAlreadySet bool) bool {
|
|
if flagAlreadySet {
|
|
return true
|
|
}
|
|
|
|
m.mu.Lock()
|
|
defer m.mu.Unlock()
|
|
if m.installing {
|
|
return false
|
|
}
|
|
m.installing = true
|
|
m.lastError = ""
|
|
return true
|
|
}
|
|
|
|
func (m *Manager) finishRuntimeInstall() {
|
|
m.mu.Lock()
|
|
m.installing = false
|
|
m.mu.Unlock()
|
|
}
|
|
|
|
func validateRuntimeVersion(runtimeVersion string) error {
|
|
if strings.TrimSpace(runtimeVersion) == "" {
|
|
return fmt.Errorf("automation runtime version is empty")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Manager) clearRuntimeInstallError() {
|
|
m.mu.Lock()
|
|
m.lastError = ""
|
|
m.mu.Unlock()
|
|
}
|