Skip to content

Commit

Permalink
offline: Reserve last 5% of progress bar for scriptlets
Browse files Browse the repository at this point in the history
There is no reliable way to estimate the number of post-transaction
scriptlets that will be executed.
The progress bar will now remain at 95% during scriptlet execution and
then jump to 100% once the transaction completes.
  • Loading branch information
m-blaha committed Mar 5, 2025
1 parent a5e931c commit 73f8a9a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dnf5/commands/offline/offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ class PlymouthTransCB : public RpmTransCB {
void elem_progress(const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) override {
RpmTransCB::elem_progress(item, amount, total);

plymouth.progress(static_cast<int>(100 * static_cast<double>(amount) / static_cast<double>(total)));
if (total != 0) {
// Reserve the last 5% of the progress bar for post-transaction callbacks.
plymouth.progress(static_cast<int>(95 * static_cast<double>(amount) / static_cast<double>(total)));
}

std::string action;
switch (item.get_action()) {
Expand Down Expand Up @@ -541,6 +544,7 @@ void OfflineExecuteCommand::run() {
transaction_complete_message = "Transaction complete! Cleaning up and rebooting...";
}

plymouth.progress(100);
plymouth.message(_(transaction_complete_message.c_str()));
dnf5::offline::log_status(
ctx, transaction_complete_message, libdnf5::offline::OFFLINE_FINISHED_ID, system_releasever, target_releasever);
Expand Down

0 comments on commit 73f8a9a

Please sign in to comment.