[gnome-software: 41/72] packagekit-refine-repos: Inline a function
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 41/72] packagekit-refine-repos: Inline a function
- Date: Wed, 15 Dec 2021 13:00:55 +0000 (UTC)
commit 5671e3e7c4a7a542f1e8a5f7f1c833942d1a6b7c
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Nov 5 17:13:50 2021 +0000
packagekit-refine-repos: Inline a function
This introduces no functional changes, but will make upcoming changes a
bit simpler.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
.../packagekit/gs-plugin-packagekit-refine-repos.c | 82 +++++++++-------------
1 file changed, 33 insertions(+), 49 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
b/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
index ce50d1115..e1bc35b9f 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
@@ -69,47 +69,6 @@ gs_plugin_packagekit_refine_repos_finalize (GObject *object)
G_OBJECT_CLASS (gs_plugin_packagekit_refine_repos_parent_class)->finalize (object);
}
-static gboolean
-gs_plugin_packagekit_refine_repo_from_filename (GsPluginPackagekitRefineRepos *self,
- GsApp *app,
- const gchar *filename,
- GCancellable *cancellable,
- GError **error)
-{
- GsPlugin *plugin = GS_PLUGIN (self);
- const gchar *to_array[] = { NULL, NULL };
- g_autoptr(GsPackagekitHelper) helper = gs_packagekit_helper_new (plugin);
- g_autoptr(PkResults) results = NULL;
- g_autoptr(GPtrArray) packages = NULL;
-
- to_array[0] = filename;
- gs_packagekit_helper_add_app (helper, app);
- g_mutex_lock (&self->client_mutex);
- pk_client_set_interactive (self->client, gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
- results = pk_client_search_files (self->client,
- pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED, -1),
- (gchar **) to_array,
- cancellable,
- gs_packagekit_helper_cb, helper,
- error);
- g_mutex_unlock (&self->client_mutex);
- if (!gs_plugin_packagekit_results_valid (results, error)) {
- g_prefix_error (error, "failed to search file %s: ", filename);
- return FALSE;
- }
-
- /* get results */
- packages = pk_results_get_package_array (results);
- if (packages->len == 1) {
- PkPackage *package = g_ptr_array_index (packages, 0);
- gs_app_add_source_id (app, pk_package_get_id (package));
- } else {
- g_debug ("failed to find one package for repo %s, %s, [%u]",
- gs_app_get_id (app), filename, packages->len);
- }
- return TRUE;
-}
-
gboolean
gs_plugin_refine (GsPlugin *plugin,
GsAppList *list,
@@ -121,23 +80,48 @@ gs_plugin_refine (GsPlugin *plugin,
for (guint i = 0; i < gs_app_list_length (list); i++) {
GsApp *app = gs_app_list_index (list, i);
- const gchar *fn;
+ const gchar *filename;
+ const gchar *to_array[] = { NULL, NULL };
+ g_autoptr(GsPackagekitHelper) helper = gs_packagekit_helper_new (plugin);
+ g_autoptr(PkResults) results = NULL;
+ g_autoptr(GPtrArray) packages = NULL;
+
if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
continue;
if (gs_app_get_kind (app) != AS_COMPONENT_KIND_REPOSITORY)
continue;
if (!gs_app_has_management_plugin (app, plugin))
continue;
- fn = gs_app_get_metadata_item (app, "repos::repo-filename");
- if (fn == NULL)
+ filename = gs_app_get_metadata_item (app, "repos::repo-filename");
+ if (filename == NULL)
continue;
+
/* set the source package name for an installed .repo file */
- if (!gs_plugin_packagekit_refine_repo_from_filename (self,
- app,
- fn,
- cancellable,
- error))
+ to_array[0] = filename;
+ gs_packagekit_helper_add_app (helper, app);
+ g_mutex_lock (&self->client_mutex);
+ pk_client_set_interactive (self->client, gs_plugin_has_flags (plugin,
GS_PLUGIN_FLAGS_INTERACTIVE));
+ results = pk_client_search_files (self->client,
+ pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED, -1),
+ (gchar **) to_array,
+ cancellable,
+ gs_packagekit_helper_cb, helper,
+ error);
+ g_mutex_unlock (&self->client_mutex);
+ if (!gs_plugin_packagekit_results_valid (results, error)) {
+ g_prefix_error (error, "failed to search file %s: ", filename);
return FALSE;
+ }
+
+ /* get results */
+ packages = pk_results_get_package_array (results);
+ if (packages->len == 1) {
+ PkPackage *package = g_ptr_array_index (packages, 0);
+ gs_app_add_source_id (app, pk_package_get_id (package));
+ } else {
+ g_debug ("failed to find one package for repo %s, %s, [%u]",
+ gs_app_get_id (app), filename, packages->len);
+ }
}
/* success */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]