diff --git a/app/flatpak-builtins-build-commit-from.c b/app/flatpak-builtins-build-commit-from.c index 584bb05c..153744d7 100644 --- a/app/flatpak-builtins-build-commit-from.c +++ b/app/flatpak-builtins-build-commit-from.c @@ -383,7 +383,7 @@ flatpak_builtin_build_commit_from (int argc, char **argv, GCancellable *cancella { OstreeRepoPullFlags pullflags = 0; GVariantBuilder builder; - g_autoptr(OstreeAsyncProgress) progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) progress = NULL; g_auto(GLnxConsoleRef) console = { 0, }; g_autoptr(GVariant) options = NULL; gboolean res; @@ -410,9 +410,6 @@ flatpak_builtin_build_commit_from (int argc, char **argv, GCancellable *cancella progress, cancellable, error); - if (progress) - ostree_async_progress_finish (progress); - if (!res) return FALSE; } diff --git a/app/flatpak-builtins-create-usb.c b/app/flatpak-builtins-create-usb.c index 7d814ca6..2b88c08c 100644 --- a/app/flatpak-builtins-create-usb.c +++ b/app/flatpak-builtins-create-usb.c @@ -261,7 +261,7 @@ ostree_create_usb (GOptionContext *context, GCancellable *cancellable, GError **error) { - g_autoptr(OstreeAsyncProgress) progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) progress = NULL; g_auto(GLnxConsoleRef) console = { 0, }; guint num_refs = 0; @@ -348,9 +348,6 @@ ostree_create_usb (GOptionContext *context, return FALSE; } - if (progress != NULL) - ostree_async_progress_finish (progress); - glnx_console_unlock (&console); } diff --git a/app/flatpak-builtins-utils.c b/app/flatpak-builtins-utils.c index 62cec51d..7fb1265f 100644 --- a/app/flatpak-builtins-utils.c +++ b/app/flatpak-builtins-utils.c @@ -661,7 +661,7 @@ update_appstream (GPtrArray *dirs, for (i = 0; remotes[i] != NULL; i++) { g_autoptr(GError) local_error = NULL; - g_autoptr(OstreeAsyncProgress) progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) progress = NULL; guint64 ts_file_age; ts_file_age = get_appstream_timestamp (dir, remotes[i], arch); @@ -706,7 +706,6 @@ update_appstream (GPtrArray *dirs, else g_printerr ("%s: %s\n", _("Error updating"), local_error->message); } - ostree_async_progress_finish (progress); } } } @@ -720,7 +719,7 @@ update_appstream (GPtrArray *dirs, if (flatpak_dir_has_remote (dir, remote, NULL)) { - g_autoptr(OstreeAsyncProgress) progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) progress = NULL; guint64 ts_file_age; found = TRUE; @@ -737,7 +736,6 @@ update_appstream (GPtrArray *dirs, progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL); res = flatpak_dir_update_appstream (dir, remote, arch, &changed, progress, cancellable, error); - ostree_async_progress_finish (progress); if (!res) return FALSE; } diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 50e15463..b7436bef 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -13495,7 +13495,7 @@ _flatpak_dir_fetch_remote_state_metadata_branch (FlatpakDir *self, GCancellable *cancellable, GError **error) { - g_autoptr(OstreeAsyncProgress) progress = ostree_async_progress_new (); + g_autoptr(OstreeAsyncProgressFinish) progress = ostree_async_progress_new (); FlatpakPullFlags flatpak_flags; gboolean gpg_verify; g_autofree char *checksum_from_summary = NULL; diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c index 0cf0e46b..429fc57d 100644 --- a/common/flatpak-installation.c +++ b/common/flatpak-installation.c @@ -2096,8 +2096,7 @@ flatpak_installation_install_full (FlatpakInstallation *self, g_autoptr(FlatpakDir) dir = NULL; g_autofree char *ref = NULL; g_autoptr(FlatpakDir) dir_clone = NULL; - g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; - FlatpakInstalledRef *result = NULL; + g_autoptr(OstreeAsyncProgressFinish) ostree_progress = NULL; g_autoptr(GFile) deploy_dir = NULL; g_autoptr(FlatpakRemoteState) state = NULL; g_autoptr(GMainContextPopDefault) main_context = NULL; @@ -2142,7 +2141,7 @@ flatpak_installation_install_full (FlatpakInstallation *self, FALSE, FALSE, state, ref, NULL, (const char **) subpaths, NULL, NULL, ostree_progress, cancellable, error)) - goto out; + return NULL; if (!(flags & FLATPAK_INSTALL_FLAGS_NO_TRIGGERS) && g_str_has_prefix (ref, "app")) @@ -2155,18 +2154,10 @@ flatpak_installation_install_full (FlatpakInstallation *self, { flatpak_fail_error (error, FLATPAK_ERROR_ONLY_PULLED, _("As requested, %s was only pulled, but not installed"), name); - goto out; + return NULL; } - result = get_ref (dir, ref, cancellable, error); - if (result == NULL) - goto out; - -out: - if (ostree_progress) - ostree_async_progress_finish (ostree_progress); - - return result; + return get_ref (dir, ref, cancellable, error); } /** @@ -2253,7 +2244,7 @@ flatpak_installation_update_full (FlatpakInstallation *self, g_autofree char *ref = NULL; g_autoptr(GFile) deploy_dir = NULL; g_autoptr(FlatpakDir) dir_clone = NULL; - g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) ostree_progress = NULL; g_autofree char *remote_name = NULL; FlatpakInstalledRef *result = NULL; g_autofree char *target_commit = NULL; @@ -2315,7 +2306,7 @@ flatpak_installation_update_full (FlatpakInstallation *self, (const OstreeRepoFinderResult * const *) check_results, (const char **) subpaths, NULL, NULL, ostree_progress, cancellable, error)) - goto out; + return NULL; if (!(flags & FLATPAK_UPDATE_FLAGS_NO_TRIGGERS) && g_str_has_prefix (ref, "app")) @@ -2323,15 +2314,12 @@ flatpak_installation_update_full (FlatpakInstallation *self, result = get_ref (dir, ref, cancellable, error); if (result == NULL) - goto out; + return NULL; /* We don't get prunable objects if not pulling or if NO_PRUNE is passed */ if (!(flags & FLATPAK_UPDATE_FLAGS_NO_PULL) && !(flags & FLATPAK_UPDATE_FLAGS_NO_PRUNE)) flatpak_dir_prune (dir_clone, cancellable, NULL); -out: - if (ostree_progress) - ostree_async_progress_finish (ostree_progress); return result; } @@ -2900,7 +2888,7 @@ flatpak_installation_update_appstream_full_sync (FlatpakInstallation *self, { g_autoptr(FlatpakDir) dir = NULL; g_autoptr(FlatpakDir) dir_clone = NULL; - g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) ostree_progress = NULL; gboolean res; g_autoptr(GMainContextPopDefault) main_context = NULL; @@ -2929,9 +2917,6 @@ flatpak_installation_update_appstream_full_sync (FlatpakInstallation *self, cancellable, error); - if (ostree_progress) - ostree_async_progress_finish (ostree_progress); - return res; } diff --git a/common/flatpak-utils-private.h b/common/flatpak-utils-private.h index 19ad6de4..490992cf 100644 --- a/common/flatpak-utils-private.h +++ b/common/flatpak-utils-private.h @@ -845,6 +845,20 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakAsyncProgressChained, flatpak_progress_unc FlatpakAsyncProgressChained *flatpak_progress_chain (OstreeAsyncProgress *progress); +static inline void +flatpak_ostree_progress_finish (OstreeAsyncProgress *progress) +{ + if (progress != NULL) + { + ostree_async_progress_finish (progress); + g_object_unref (progress); + } +} + +typedef OstreeAsyncProgress OstreeAsyncProgressFinish; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeAsyncProgressFinish, flatpak_ostree_progress_finish); + + void flatpak_log_dir_access (FlatpakDir *dir); gboolean flatpak_check_required_version (const char *ref, diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c index 8d11f181..7f53b39c 100644 --- a/system-helper/flatpak-system-helper.c +++ b/system-helper/flatpak-system-helper.c @@ -386,7 +386,7 @@ handle_deploy (FlatpakSystemHelper *object, g_autoptr(GFile) repo_file = g_file_new_for_path (arg_repo_path); g_autoptr(GError) error = NULL; g_autoptr(GFile) deploy_dir = NULL; - g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) ostree_progress = NULL; gboolean is_oci; gboolean is_update; gboolean no_deploy; @@ -638,9 +638,6 @@ handle_deploy (FlatpakSystemHelper *object, flatpak_invocation_return_error (invocation, error, "Error pulling from repo"); return TRUE; } - - if (ostree_progress) - ostree_async_progress_finish (ostree_progress); } else if (local_pull) { @@ -681,9 +678,6 @@ handle_deploy (FlatpakSystemHelper *object, flatpak_invocation_return_error (invocation, error, "Error pulling from repo"); return TRUE; } - - if (ostree_progress) - ostree_async_progress_finish (ostree_progress); } if (!no_deploy) @@ -848,7 +842,7 @@ handle_deploy_appstream (FlatpakSystemHelper *object, g_autoptr(GError) first_error = NULL; g_autoptr(GError) second_error = NULL; g_autoptr(GMainContextPopDefault) main_context = NULL; - g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) ostree_progress = NULL; /* Work around ostree-pull spinning the default main context for the sync calls */ main_context = flatpak_main_context_new_default (); @@ -880,7 +874,7 @@ handle_deploy_appstream (FlatpakSystemHelper *object, else /* empty path == local pull */ { g_autoptr(FlatpakRemoteState) state = NULL; - g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; + g_autoptr(OstreeAsyncProgressFinish) ostree_progress = NULL; g_autoptr(GError) first_error = NULL; g_autoptr(GError) second_error = NULL; g_autofree char *url = NULL; @@ -929,9 +923,6 @@ handle_deploy_appstream (FlatpakSystemHelper *object, return TRUE; } } - - if (ostree_progress) - ostree_async_progress_finish (ostree_progress); } if (!flatpak_dir_deploy_appstream (system,