diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-02-12 09:57:38 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-02-12 13:12:37 +0100 |
commit | 2eb2117cdf18389dfb6e3ad94b63304fb1500bd4 (patch) | |
tree | 8df1f96c7e9f067e7032f29c00213f5ef135b8b4 /libappstream-glib/as-store.c | |
parent | e625941265a086c7bb00d8536e42f3dfe2f57c3e (diff) | |
download | appstream-glib-2eb2117cdf18389dfb6e3ad94b63304fb1500bd4.tar.gz |
store: Keep track of which appinfo dirs are added and never re-add them
We monitor these for changes anyway, so it would not make sense to re-scan
then.
This doesn't affect anything yet, because we only scan at
initialization, but it will be required to pick up new appinfo dirs as
new xdg-app remotes are added.
Diffstat (limited to 'libappstream-glib/as-store.c')
-rw-r--r-- | libappstream-glib/as-store.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index a1674d1..5ba7ed1 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -68,6 +68,7 @@ typedef struct GHashTable *hash_pkgname; /* of AsApp{pkgname} */ AsMonitor *monitor; GHashTable *metadata_indexes; /* GHashTable{key} */ + GHashTable *appinfo_dirs; /* GHashTable{path} */ AsStoreAddFlags add_flags; AsStoreWatchFlags watch_flags; AsStoreProblems problems; @@ -115,6 +116,7 @@ as_store_finalize (GObject *object) g_hash_table_unref (priv->hash_id); g_hash_table_unref (priv->hash_pkgname); g_hash_table_unref (priv->metadata_indexes); + g_hash_table_unref (priv->appinfo_dirs); G_OBJECT_CLASS (as_store_parent_class)->finalize (object); } @@ -1794,6 +1796,10 @@ as_store_load_app_info (AsStore *store, g_autoptr(GError) error_local = NULL; _cleanup_uninhibit_ guint32 *tok = NULL; + /* Don't add the same dir twice, we're monitoring it for changes anyway */ + if (g_hash_table_contains (priv->appinfo_dirs, path)) + return TRUE; + /* emit once when finished */ tok = as_store_changed_inhibit (store); @@ -1809,6 +1815,7 @@ as_store_load_app_info (AsStore *store, path, error_local->message); return FALSE; } + while ((tmp = g_dir_read_name (dir)) != NULL) { GError *error_store = NULL; g_autofree gchar *filename_md = NULL; @@ -1837,6 +1844,8 @@ as_store_load_app_info (AsStore *store, error)) return FALSE; + g_hash_table_insert (priv->appinfo_dirs, g_strdup (path), NULL); + /* emit changed */ as_store_changed_uninhibit (&tok); as_store_perhaps_emit_changed (store, "load-app-info"); @@ -2477,6 +2486,10 @@ as_store_init (AsStore *store) g_str_equal, g_free, (GDestroyNotify) g_object_unref); + priv->appinfo_dirs = g_hash_table_new_full (g_str_hash, + g_str_equal, + NULL, + NULL); priv->monitor = as_monitor_new (); g_signal_connect (priv->monitor, "changed", G_CALLBACK (as_store_monitor_changed_cb), |