Skip to content

Commit

Permalink
Fix: Properly clean unstaged queue
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Aug 10, 2023
1 parent 34331b0 commit 9e93996
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 0 additions & 5 deletions core/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,6 @@ func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string {
if operation == APPLY {
finalAddPkgs, finalRemovePkgs = p.processApplyPackages()
} else {
err := p.ClearUnstagedPackages()
if err != nil {
PrintVerbose("PackageManager.GetFinalCmd:err: %s", err.Error())
panic(err)
}
finalAddPkgs, finalRemovePkgs = p.processUpgradePackages()
}

Expand Down
20 changes: 13 additions & 7 deletions core/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"os"
"os/exec"
"path/filepath"
"sort"
"strings"

"github.com/google/uuid"
Expand Down Expand Up @@ -183,13 +184,9 @@ func (s *ABSystem) SyncUpperEtc(newEtc string) error {
func (s *ABSystem) RunCleanUpQueue(fnName string) error {
PrintVerbose("ABSystem.RunCleanUpQueue: running...")

for i := 0; i < len(queue); i++ {
for j := 0; j < len(queue)-1; j++ {
if queue[j].Priority > queue[j+1].Priority {
queue[j], queue[j+1] = queue[j+1], queue[j]
}
}
}
sort.Slice(queue, func(i, j int) bool {
return queue[i].Priority < queue[j].Priority
})

for _, f := range queue {
if fnName != "" && f.Name != fnName {
Expand Down Expand Up @@ -234,6 +231,13 @@ func (s *ABSystem) RunCleanUpQueue(fnName string) error {
PrintVerbose("ABSystem.RunCleanUpQueue:err(6): %s", err)
return err
}
case "clearUnstagedPackages":
pkgM := NewPackageManager()
err := pkgM.ClearUnstagedPackages()
if err != nil {
PrintVerbose("ABSystem.RunCleanUpQueue:err(7): %s", err)
return err
}
}
}

Expand Down Expand Up @@ -613,6 +617,8 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error {
return err
}

s.AddToCleanUpQueue("clearUnstagedPackages", 10)

// Stage 5: Write abimage.abr.new to future/
// ------------------------------------------------
PrintVerbose("[Stage 5] ABSystemRunOperation")
Expand Down

0 comments on commit 9e93996

Please sign in to comment.