summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-store.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-04-25 17:38:33 +0100
committerRichard Hughes <richard@hughsie.com>2016-04-25 17:38:33 +0100
commit55714fa11b112ff19b0f7bda22f828099cbb43ce (patch)
treec4e0ba41e97383eb4585bb580429f99b3fc58a76 /libappstream-glib/as-store.c
parent9269ec6dd8b7ed8122dfaff9e3c117818f3c50be (diff)
downloadappstream-glib-55714fa11b112ff19b0f7bda22f828099cbb43ce.tar.gz
Ignore files with invalid suffixes when building installed stores
Fixes https://github.com/hughsie/appstream-glib/issues/99
Diffstat (limited to 'libappstream-glib/as-store.c')
-rw-r--r--libappstream-glib/as-store.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 922c4e9..24afe75 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -2208,6 +2208,22 @@ as_store_set_app_installed (AsApp *app)
}
/**
+ * as_store_load_installed_file_is_valid:
+ **/
+static gboolean
+as_store_load_installed_file_is_valid (const gchar *filename)
+{
+ if (g_str_has_suffix (filename, ".desktop"))
+ return TRUE;
+ if (g_str_has_suffix (filename, ".metainfo.xml"))
+ return TRUE;
+ if (g_str_has_suffix (filename, ".appdata.xml"))
+ return TRUE;
+ g_debug ("ignoring filename with invalid suffix: %s", filename);
+ return FALSE;
+}
+
+/**
* as_store_load_installed:
**/
static gboolean
@@ -2252,7 +2268,7 @@ as_store_load_installed (AsStore *store,
g_autofree gchar *filename = NULL;
g_autoptr(AsApp) app = NULL;
filename = g_build_filename (path, tmp, NULL);
- if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
+ if (!as_store_load_installed_file_is_valid (filename))
continue;
if ((priv->add_flags & AS_STORE_ADD_FLAG_PREFER_LOCAL) == 0) {
app_tmp = as_store_get_app_by_id (store, tmp);