Skip to content

Commit

Permalink
Fix: Defer RunCleanUpQueue in root switching operation
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Aug 12, 2023
1 parent be0fdd9 commit 86525a9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,50 +211,50 @@ func (s *ABSystem) RunCleanUpQueue(fnName string) error {

switch f.Name {
case "umountFuture":
PrintVerbose("ABSystem.RunCleanUpQueue: Executing umountFuture")
PrintVerbose("ABSystem.RunCleanUpQueue: Executing umountFuture")
futurePart := f.Values[0].(ABRootPartition)
err := futurePart.Partition.Unmount()
if err != nil {
PrintVerbose("ABSystem.RunCleanUpQueue:err: %s", err)
return err
}
case "closeChroot":
PrintVerbose("ABSystem.RunCleanUpQueue: Executing closeChroot")
PrintVerbose("ABSystem.RunCleanUpQueue: Executing closeChroot")
chroot := f.Values[0].(*Chroot)
chroot.Close() // safe to ignore, already closed
case "removeNewSystem":
PrintVerbose("ABSystem.RunCleanUpQueue: Executing removeNewSystem")
PrintVerbose("ABSystem.RunCleanUpQueue: Executing removeNewSystem")
newSystem := f.Values[0].(string)
err := os.RemoveAll(newSystem)
if err != nil {
PrintVerbose("ABSystem.RunCleanUpQueue:err(3): %s", err)
return err
}
case "removeNewABImage":
PrintVerbose("ABSystem.RunCleanUpQueue: Executing removeNewABImage")
PrintVerbose("ABSystem.RunCleanUpQueue: Executing removeNewABImage")
newImage := f.Values[0].(string)
err := os.RemoveAll(newImage)
if err != nil {
PrintVerbose("ABSystem.RunCleanUpQueue:err(4): %s", err)
return err
}
case "umountBoot":
PrintVerbose("ABSystem.RunCleanUpQueue: Executing umountBoot")
PrintVerbose("ABSystem.RunCleanUpQueue: Executing umountBoot")
bootPart := f.Values[0].(Partition)
err := bootPart.Unmount()
if err != nil {
PrintVerbose("ABSystem.RunCleanUpQueue:err(5): %s", err)
return err
}
case "unlockUpgrade":
PrintVerbose("ABSystem.RunCleanUpQueue: Executing unlockUpgrade")
PrintVerbose("ABSystem.RunCleanUpQueue: Executing unlockUpgrade")
err := s.UnlockUpgrade()
if err != nil {
PrintVerbose("ABSystem.RunCleanUpQueue:err(6): %s", err)
return err
}
case "clearUnstagedPackages":
PrintVerbose("ABSystem.RunCleanUpQueue: Executing clearUnstagedPackages")
PrintVerbose("ABSystem.RunCleanUpQueue: Executing clearUnstagedPackages")
pkgM := NewPackageManager()
err := pkgM.ClearUnstagedPackages()
if err != nil {
Expand Down Expand Up @@ -466,6 +466,8 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error {

s.ResetQueue()

defer s.RunCleanUpQueue("")

// Stage 0: Check if upgrade is possible
// -------------------------------------
PrintVerbose("[Stage 0] -------- ABSystemRunOperation")
Expand Down Expand Up @@ -501,7 +503,6 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error {
if !res {
if operation != FOCE_UPGRADE {
PrintVerbose("ABSystemRunOperation:err(1.1): %s", err)
s.RunCleanUpQueue("")
return NoUpdateError
}
PrintVerbose("ABSystemRunOperation: No update available but --force is set. Proceeding...")
Expand Down Expand Up @@ -872,7 +873,6 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error {
}

PrintVerbose("ABSystem.RunOperation: upgrade completed")
s.RunCleanUpQueue("")
return nil
}

Expand Down

0 comments on commit 86525a9

Please sign in to comment.