summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-02-15 15:00:49 +0000
committerRichard Hughes <richard@hughsie.com>2016-02-16 20:01:01 +0000
commitd29c62ecc9c30ca42718e2ec89698de9f061f52a (patch)
treea91b33ad802e1de23d9f770cc93436948f7fc6d8
parentab5b41e99448b9561fed75562af0cd96611b216a (diff)
downloadappstream-glib-d29c62ecc9c30ca42718e2ec89698de9f061f52a.tar.gz
Look in the correct icon directory for yaml files
Fixes https://github.com/hughsie/appstream-glib/pull/92
-rw-r--r--data/tests/Makefile.am4
-rw-r--r--data/tests/usr/share/app-info/icons/aequorea/iceweasel.png (renamed from data/tests/usr/share/app-install/icons/aequorea/iceweasel.png)0
-rw-r--r--data/tests/usr/share/app-info/yaml/aequorea.yml (renamed from data/tests/example.yml)0
-rw-r--r--libappstream-glib/as-self-test.c9
-rw-r--r--libappstream-glib/as-store.c19
5 files changed, 18 insertions, 14 deletions
diff --git a/data/tests/Makefile.am b/data/tests/Makefile.am
index 426373e..cf8d5f5 100644
--- a/data/tests/Makefile.am
+++ b/data/tests/Makefile.am
@@ -18,7 +18,6 @@ test_files = \
example.metainfo.xml \
example-v04.xml.gz \
example-v06.yml.gz \
- example.yml \
firmware/2_0_0/firmware.bin \
firmware/2_0_0/firmware.inf \
firmware/2_0_1/firmware.bin \
@@ -40,7 +39,8 @@ test_files = \
test-0.1-1.fc21.noarch.rpm \
translated.appdata.xml \
usr/share/appdata/broken.appdata.xml \
- usr/share/app-install/icons/aequorea/iceweasel.png \
+ usr/share/app-info/icons/aequorea/iceweasel.png \
+ usr/share/app-info/yaml/aequorea.yml \
usr/share/applications/broken.desktop \
usr/share/applications/test.desktop \
usr/share/icons/hicolor/64x64/apps/test2.png \
diff --git a/data/tests/usr/share/app-install/icons/aequorea/iceweasel.png b/data/tests/usr/share/app-info/icons/aequorea/iceweasel.png
index e69de29..e69de29 100644
--- a/data/tests/usr/share/app-install/icons/aequorea/iceweasel.png
+++ b/data/tests/usr/share/app-info/icons/aequorea/iceweasel.png
diff --git a/data/tests/example.yml b/data/tests/usr/share/app-info/yaml/aequorea.yml
index cca1091..cca1091 100644
--- a/data/tests/example.yml
+++ b/data/tests/usr/share/app-info/yaml/aequorea.yml
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 5f982f5..d538e0e 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -3970,7 +3970,7 @@ as_test_yaml_func (void)
as_yaml_unref (node);
/* dummy application */
- filename = as_test_get_filename ("example.yml");
+ filename = as_test_get_filename ("usr/share/app-info/yaml/aequorea.yml");
g_assert (filename != NULL);
file = g_file_new_for_path (filename);
node = as_yaml_from_file (file, NULL, &error);
@@ -4025,7 +4025,6 @@ as_test_store_yaml_func (void)
GError *error = NULL;
gboolean ret;
g_autofree gchar *filename = NULL;
- g_autofree gchar *icon_root = NULL;
g_autoptr(AsStore) store = NULL;
g_autoptr(GFile) file = NULL;
g_autoptr(GString) str = NULL;
@@ -4054,10 +4053,10 @@ as_test_store_yaml_func (void)
/* load store */
store = as_store_new ();
- filename = as_test_get_filename ("example.yml");
- icon_root = as_test_get_filename ("usr/share/app-install/icons");
+ filename = as_test_get_filename ("usr/share/app-info/yaml/aequorea.yml");
+ g_assert (filename != NULL);
file = g_file_new_for_path (filename);
- ret = as_store_from_file (store, file, icon_root, NULL, &error);
+ ret = as_store_from_file (store, file, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index be8ca57..a432798 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -942,7 +942,9 @@ as_store_from_root (AsStore *store,
if (icon_prefix != NULL) {
g_autofree gchar *topdir = NULL;
topdir = g_path_get_basename (icon_prefix);
- if (g_strcmp0 (topdir, "xmls") == 0 && priv->origin != NULL) {
+ if ((g_strcmp0 (topdir, "xmls") == 0 ||
+ g_strcmp0 (topdir, "yaml") == 0)
+ && priv->origin != NULL) {
g_autofree gchar *dirname = NULL;
dirname = g_path_get_dirname (icon_prefix);
icon_path = g_build_filename (dirname,
@@ -1013,7 +1015,6 @@ as_store_from_root (AsStore *store,
static gboolean
as_store_load_yaml_file (AsStore *store,
GFile *file,
- const gchar *icon_root,
GCancellable *cancellable,
GError **error)
{
@@ -1047,9 +1048,14 @@ as_store_load_yaml_file (AsStore *store,
/* if we have an origin either from the YAML or _set_origin() */
if (priv->origin != NULL) {
- if (icon_root == NULL)
- icon_root = "/usr/share/app-info/icons/";
- icon_path = g_build_filename (icon_root,
+ g_autofree gchar *filename = NULL;
+ g_autofree gchar *icon_prefix1 = NULL;
+ g_autofree gchar *icon_prefix2 = NULL;
+ filename = g_file_get_path (file);
+ icon_prefix1 = g_path_get_dirname (filename);
+ icon_prefix2 = g_path_get_dirname (icon_prefix1);
+ icon_path = g_build_filename (icon_prefix2,
+ "icons",
priv->origin,
NULL);
}
@@ -1260,8 +1266,7 @@ as_store_from_file (AsStore *store,
/* a DEP-11 file */
filename = g_file_get_path (file);
if (g_strstr_len (filename, -1, ".yml") != NULL)
- return as_store_load_yaml_file (store, file, icon_root,
- cancellable, error);
+ return as_store_load_yaml_file (store, file, cancellable, error);
#ifdef HAVE_GCAB
/* a cab archive */