Commit 197e62f4 authored by Roman Alifanov's avatar Roman Alifanov

Add RebootRequired to UpdateCategory, use for reboot button logic

parent 7a754a31
......@@ -4,6 +4,7 @@ type UpdateCategory struct {
Name string
Enabled bool // User can toggle this category
Available bool // Has updates available
RebootRequired bool
Packages []Package
DownloadSize uint64
InstallSize int64
......
......@@ -148,7 +148,13 @@ func (us *UpdateService) RunUpdates(ctx context.Context) error {
startTime := time.Now()
packagesUpdated := 0
var categoryErrors []string
systemOrKernelSucceeded := false
rebootRequired := false
categoryMap := map[string]*model.UpdateCategory{
"System": state.SystemUpdates,
"Kernel": state.KernelUpdates,
"Play": state.PlayUpdates,
}
// Execute updates sequentially
for _, category := range categories {
......@@ -158,13 +164,11 @@ func (us *UpdateService) RunUpdates(ctx context.Context) error {
continue
}
switch category {
case "System":
packagesUpdated += len(state.SystemUpdates.Packages)
systemOrKernelSucceeded = true
case "Kernel":
packagesUpdated += len(state.KernelUpdates.Packages)
systemOrKernelSucceeded = true
if cat, ok := categoryMap[category]; ok {
packagesUpdated += len(cat.Packages)
if cat.RebootRequired {
rebootRequired = true
}
}
}
......@@ -176,7 +180,7 @@ func (us *UpdateService) RunUpdates(ctx context.Context) error {
us.store.Dispatch(&store.FinishUpdateAction{
Success: success,
Error: strings.Join(categoryErrors, "; "),
SystemOrKernelSucceeded: systemOrKernelSucceeded,
RebootRequired: rebootRequired,
})
// Record in history
......
......@@ -28,6 +28,7 @@ func (a *LoadSystemUpdatesAction) Apply(state *State) error {
state.SystemUpdates.Packages = append(state.SystemUpdates.Packages, a.Changes.Install...)
state.SystemUpdates.DownloadSize = a.Changes.DownloadSize
state.SystemUpdates.InstallSize = a.Changes.InstallSize
state.SystemUpdates.RebootRequired = true
state.SystemUpdates.LastChecked = time.Now().Format(time.RFC3339)
return nil
}
......@@ -42,6 +43,7 @@ func (a *LoadKernelUpdatesAction) Apply(state *State) error {
state.KernelUpdates.Packages = append(state.KernelUpdates.Packages, a.Info.Packages.Install...)
state.KernelUpdates.DownloadSize = a.Info.Packages.DownloadSize
state.KernelUpdates.InstallSize = a.Info.Packages.InstallSize
state.KernelUpdates.RebootRequired = true
state.KernelUpdates.LastChecked = time.Now().Format(time.RFC3339)
return nil
}
......@@ -126,7 +128,7 @@ func (a *UpdateProgressAction) Apply(state *State) error {
type FinishUpdateAction struct {
Success bool
Error string
SystemOrKernelSucceeded bool
RebootRequired bool
}
func (a *FinishUpdateAction) Apply(state *State) error {
......
......@@ -136,8 +136,7 @@ func (w *Window) onStateChange(change store.StateChange) {
case store.ChangeUpdateFinish:
action, ok := change.Data.(*store.FinishUpdateAction)
if ok {
showReboot := action.Success || action.SystemOrKernelSucceeded
w.processPage.ShowComplete(action.Success, showReboot)
w.processPage.ShowComplete(action.Success, action.RebootRequired)
}
case store.ChangeHistory:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment