[gnome-software: 3/6] appstream: appstream files from user-data dirs when appropriate
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 3/6] appstream: appstream files from user-data dirs when appropriate
- Date: Mon, 10 Jan 2022 12:52:35 +0000 (UTC)
commit 7e9d55a3565b059b65c81bcb12b630b047fc33a5
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date: Tue Dec 28 20:04:07 2021 +0100
appstream: appstream files from user-data dirs when appropriate
gs_external_appstream_refresh_user installs external
appstream files in non-standard XDG_DATA_HOME directory.
Make sure that the corresponding xml and yaml directories
are read so that the installed files do not get ignored.
Additionally, changes to "external-appstream-system-wide" can leave old
files in the directories where the files are installed. Make sure we do not
read those undesired files. When the key is TRUE, it is enough to
ignore the custom location where user files are installed, as it is
a non-standard location only used by GNOME Software. However, when
the key is FALSE, ignoring the system directory where the system
files are installed is a mistake, as /var/cache/app-info/xmls is
a standard directory and other programs might install files there.
In this case, match also the prefix to make sure we are only ignoring
our own dirty files
plugins/core/gs-plugin-appstream.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index b5dd439b3..2c7d6f416 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -14,6 +14,7 @@
#include <xmlb.h>
#include "gs-appstream.h"
+#include "gs-external-appstream-utils.h"
#include "gs-plugin-appstream.h"
/*
@@ -490,6 +491,14 @@ gs_plugin_appstream_load_appstream (GsPluginAppstream *self,
if (dir == NULL)
return FALSE;
while ((fn = g_dir_read_name (dir)) != NULL) {
+#ifdef ENABLE_EXTERNAL_APPSTREAM
+ /* Ignore our own system-installed files when
+ external-appstream-system-wide is FALSE */
+ if (!g_settings_get_boolean (self->settings, "external-appstream-system-wide") &&
+ g_strcmp0 (path, gs_external_appstream_utils_get_system_dir ()) == 0 &&
+ g_str_has_prefix (fn, EXTERNAL_APPSTREAM_PREFIX))
+ continue;
+#endif
if (g_str_has_suffix (fn, ".xml") ||
g_str_has_suffix (fn, ".yml") ||
g_str_has_suffix (fn, ".yml.gz") ||
@@ -599,6 +608,15 @@ gs_plugin_appstream_check_silo (GsPluginAppstream *self,
g_build_filename (LOCALSTATEDIR, "lib", "app-info", "xmls", NULL));
g_ptr_array_add (parent_appstream,
g_build_filename (LOCALSTATEDIR, "lib", "app-info", "yaml", NULL));
+#ifdef ENABLE_EXTERNAL_APPSTREAM
+ /* check for the corresponding setting */
+ if (!g_settings_get_boolean (self->settings, "external-appstream-system-wide")) {
+ g_ptr_array_add (parent_appstream,
+ g_build_filename (g_get_user_data_dir (), "app-info", "xmls", NULL));
+ g_ptr_array_add (parent_appstream,
+ g_build_filename (g_get_user_data_dir (), "app-info", "yaml", NULL));
+ }
+#endif
/* Add the normal system directories if the installation prefix
* is different from normal — typically this happens when doing
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]