Implement self-update recovery (T-403)
This commit is contained in:
@@ -19,6 +19,12 @@ import (
|
||||
const applicationEventCapacity = 32
|
||||
|
||||
func main() {
|
||||
if handled, err := acknowledgeInternalUpdateHealth(os.Args[1:]); handled {
|
||||
if err != nil {
|
||||
log.Printf("%s internal update health failed: %v", core.ProductName, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
if err := run(); err != nil {
|
||||
log.Printf("%s stopped: %v", core.ProductName, err)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"softbox.local/app-modern/platform/windows"
|
||||
"softbox.local/core/updater"
|
||||
)
|
||||
|
||||
func acknowledgeInternalUpdateHealth(arguments []string) (bool, error) {
|
||||
if len(arguments) == 0 || arguments[0] != updater.InternalHealthFlag {
|
||||
return false, nil
|
||||
}
|
||||
if len(arguments) != 2 {
|
||||
return true, fmt.Errorf("%s requires exactly one internal request ID", updater.InternalHealthFlag)
|
||||
}
|
||||
executable, err := os.Executable()
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("locate current executable: %w", err)
|
||||
}
|
||||
if err := updater.AcknowledgeHealthFromExecutable(executable, arguments[1], windows.New()); err != nil {
|
||||
return true, fmt.Errorf("acknowledge self-update health: %w", err)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
Reference in New Issue
Block a user