Commit 336becd3 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Nate Graham
Browse files

flatpak: Address transaction progress skipping

Flatpak transaction progress skips back and forth as it is reported
according its different operations.
Report the progress according equally split among the different
operations.

BUG: 404819
BUG: 434948
BUG: 435450
BUG: 448280


(cherry picked from commit 8226ddf1)
parent a3dd72f4
Pipeline #247258 passed with stage
in 2 minutes and 37 seconds
......@@ -29,11 +29,14 @@ gboolean FlatpakTransactionThread::add_new_remote_cb(FlatpakTransaction *object,
return true;
}
static void progress_changed_cb(FlatpakTransactionProgress *progress, gpointer user_data)
void FlatpakTransactionThread::progress_changed_cb(FlatpakTransactionProgress *progress, gpointer user_data)
{
FlatpakTransactionThread *obj = (FlatpakTransactionThread *)user_data;
obj->setProgress(qMin(99, flatpak_transaction_progress_get_progress(progress)));
g_autolist(GObject) ops = flatpak_transaction_get_operations(obj->m_transaction);
g_autoptr(FlatpakTransactionOperation) op = flatpak_transaction_get_current_operation(obj->m_transaction);
const int idx = g_list_index(ops, op);
obj->setProgress(qMin<int>(99, (100 * idx + flatpak_transaction_progress_get_progress(progress)) / g_list_length(ops)));
#ifdef FLATPAK_VERBOSE_PROGRESS
guint64 start_time = flatpak_transaction_progress_get_start_time(progress);
......@@ -45,11 +48,14 @@ static void progress_changed_cb(FlatpakTransactionProgress *progress, gpointer u
#endif
}
void new_operation_cb(FlatpakTransaction * /*object*/, FlatpakTransactionOperation * /*operation*/, FlatpakTransactionProgress *progress, gpointer user_data)
void FlatpakTransactionThread::new_operation_cb(FlatpakTransaction * /*object*/,
FlatpakTransactionOperation * /*operation*/,
FlatpakTransactionProgress *progress,
gpointer user_data)
{
FlatpakTransactionThread *obj = (FlatpakTransactionThread *)user_data;
g_signal_connect(progress, "changed", G_CALLBACK(progress_changed_cb), obj);
g_signal_connect(progress, "changed", G_CALLBACK(&FlatpakTransactionThread::progress_changed_cb), obj);
flatpak_transaction_progress_set_update_frequency(progress, FLATPAK_CLI_UPDATE_FREQUENCY);
}
......
......@@ -57,6 +57,9 @@ Q_SIGNALS:
private:
static gboolean
add_new_remote_cb(FlatpakTransaction * /*object*/, gint /*reason*/, gchar *from_id, gchar *suggested_remote_name, gchar *url, gpointer user_data);
static void progress_changed_cb(FlatpakTransactionProgress *progress, gpointer user_data);
static void
new_operation_cb(FlatpakTransaction * /*object*/, FlatpakTransactionOperation *operation, FlatpakTransactionProgress *progress, gpointer user_data);
static gboolean webflowStart(FlatpakTransaction *transaction, const char *remote, const char *url, GVariant *options, guint id, gpointer user_data);
static void webflowDoneCallback(FlatpakTransaction *transaction, GVariant *options, guint id, gpointer user_data);
......
......@@ -116,6 +116,12 @@ private Q_SLOTS:
private:
Transaction::Status waitTransaction(Transaction *t)
{
int lastProgress = -1;
connect(t, &Transaction::progressChanged, this, [t, &lastProgress] {
Q_ASSERT(lastProgress <= t->progress());
lastProgress = t->progress();
});
TransactionModel::global()->addTransaction(t);
QSignalSpy spyInstalled(TransactionModel::global(), &TransactionModel::transactionRemoved);
QSignalSpy destructionSpy(t, &QObject::destroyed);
......
Supports Markdown
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