Issue actual erasure progress callbacks too
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 5 Jan 2012 13:18:28 +0000 (15:18 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 5 Jan 2012 14:05:11 +0000 (16:05 +0200)
- Whereas on install the progress is measured by bytes written to
  disk vs total archive size, on erase the best we can do is
  going by the number of files in the package. Fsm iterates backwards
  on erase so we can't just use fsm->ix but need to re-revert the value.

lib/fsm.c

index 8df04b3..075e134 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1677,6 +1677,9 @@ static int fsmStage(FSM_t fsm, fileStage stage)
            /* Rename/erase next item. */
            if (fsmNext(fsm, FSM_FINI))
                break;
+
+           /* Notify on success. */
+           (void) fsmNext(fsm, FSM_NOTIFY);
        }
        break;
     case FSM_PKGBUILD:
@@ -1886,6 +1889,11 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
     case FSM_NOTIFY:           /* XXX move from fsm to psm -> tsm */
        if (fsm->goal == FSM_PKGINSTALL) {
            rpmpsmNotify(fsm->psm, RPMCALLBACK_INST_PROGRESS, fsm->cpioPos);
+       } else if (fsm->goal == FSM_PKGERASE) {
+           /* On erase we're iterating backwards, fixup for progress */
+           rpm_loff_t amount = (fsm->ix >= 0) ?
+                               rpmfiFC(fsmGetFi(fsm)) - fsm->ix : 0;
+           rpmpsmNotify(fsm->psm, RPMCALLBACK_UNINST_PROGRESS, amount);
        }
        break;
     case FSM_UNDO: