[gnome-software] trivial: Use the xdg-app branch name if the version is not available
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Use the xdg-app branch name if the version is not available
- Date: Wed, 10 Feb 2016 14:05:01 +0000 (UTC)
commit 44b923507d3994ef2785253f33072769f464f7af
Author: Richard Hughes <richard hughsie com>
Date: Wed Feb 10 13:56:46 2016 +0000
trivial: Use the xdg-app branch name if the version is not available
src/plugins/gs-plugin-xdg-app-reviews.c | 9 ++++++++-
src/plugins/gs-plugin-xdg-app.c | 9 +++++++++
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-xdg-app-reviews.c b/src/plugins/gs-plugin-xdg-app-reviews.c
index ba4e938..8b15108 100644
--- a/src/plugins/gs-plugin-xdg-app-reviews.c
+++ b/src/plugins/gs-plugin-xdg-app-reviews.c
@@ -89,6 +89,7 @@ gs_plugin_get_deps (GsPlugin *plugin)
{
static const gchar *deps[] = {
"appstream", /* need application IDs */
+ "xdg-app", /* need version */
NULL };
return deps;
}
@@ -532,6 +533,7 @@ gs_plugin_refine_ratings (GsPlugin *plugin,
static GPtrArray *
xdg_app_review_fetch_for_app (GsPlugin *plugin, GsApp *app, GError **error)
{
+ const gchar *version;
guint karma_min;
guint status_code;
g_autofree gchar *cachedir = NULL;
@@ -560,6 +562,11 @@ xdg_app_review_fetch_for_app (GsPlugin *plugin, GsApp *app, GError **error)
return xdg_app_review_parse_reviews (json_data, -1, error);
}
+ /* not always available */
+ version = gs_app_get_version (app);
+ if (version == NULL)
+ version = "unknown";
+
/* create object with review data */
builder = json_builder_new ();
json_builder_begin_object (builder);
@@ -572,7 +579,7 @@ xdg_app_review_fetch_for_app (GsPlugin *plugin, GsApp *app, GError **error)
json_builder_set_member_name (builder, "distro");
json_builder_add_string_value (builder, plugin->priv->distro);
json_builder_set_member_name (builder, "version");
- json_builder_add_string_value (builder, gs_app_get_version (app));
+ json_builder_add_string_value (builder, version);
json_builder_set_member_name (builder, "limit");
json_builder_add_int_value (builder, XDG_APP_REVIEW_NUMBER_RESULTS_MAX);
json_builder_set_member_name (builder, "karma");
diff --git a/src/plugins/gs-plugin-xdg-app.c b/src/plugins/gs-plugin-xdg-app.c
index a3b52fb..be86760 100644
--- a/src/plugins/gs-plugin-xdg-app.c
+++ b/src/plugins/gs-plugin-xdg-app.c
@@ -782,6 +782,15 @@ gs_plugin_refine_item (GsPlugin *plugin,
if (!gs_plugin_refine_item_action (plugin, app, cancellable, error))
return FALSE;
+ /* version fallback */
+ if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION) {
+ if (gs_app_get_version (app) == NULL) {
+ const gchar *branch;
+ branch = gs_app_get_metadata_item (app, "XgdApp::branch");
+ gs_app_set_version (app, branch);
+ }
+ }
+
/* size */
if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) {
if (!gs_plugin_refine_item_size (plugin, app, cancellable, error))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]