[gnome-software] appstream: Monitor appstream and appdata directories rather than files



commit cad39ecfc61172706a64a68c56c16ad0d74a46bf
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Jun 3 10:05:43 2020 +0100

    appstream: Monitor appstream and appdata directories rather than files
    
    Use the new `XB_BUILDER_SOURCE_FLAG_WATCH_DIRECTORY` API from
    https://github.com/hughsie/libxmlb/pull/55 to only monitor appstream and
    appdata directories, rather than all O(N) files within them. This
    shouldn’t change functionality, but should reduce the number of file
    monitors in use by an order of magnitude.
    
    In particular, it drops around 200KB of heap memory usage directly
    associated with those file monitors, and potentially a little more
    that’s indirectly associated (signal connections and closures, main
    context sources, etc.).
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 plugins/core/gs-plugin-appstream.c | 12 ++++++++++++
 plugins/flatpak/gs-flatpak.c       |  4 ++++
 2 files changed, 16 insertions(+)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 548f03eb..d58d6320 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -142,7 +142,11 @@ gs_plugin_appstream_load_appdata_fn (GsPlugin *plugin,
 
        /* add source */
        if (!xb_builder_source_load_file (source, file,
+#if LIBXMLB_CHECK_VERSION(0, 2, 0)
+                                         XB_BUILDER_SOURCE_FLAG_WATCH_DIRECTORY,
+#else
                                          XB_BUILDER_SOURCE_FLAG_WATCH_FILE,
+#endif
                                          cancellable,
                                          error)) {
                return FALSE;
@@ -243,7 +247,11 @@ gs_plugin_appstream_load_desktop_fn (GsPlugin *plugin,
 
        /* add source */
        if (!xb_builder_source_load_file (source, file,
+#if LIBXMLB_CHECK_VERSION(0, 2, 0)
+                                         XB_BUILDER_SOURCE_FLAG_WATCH_DIRECTORY,
+#else
                                          XB_BUILDER_SOURCE_FLAG_WATCH_FILE,
+#endif
                                          cancellable,
                                          error)) {
                return FALSE;
@@ -341,7 +349,11 @@ gs_plugin_appstream_load_appstream_fn (GsPlugin *plugin,
 
        /* add source */
        if (!xb_builder_source_load_file (source, file,
+#if LIBXMLB_CHECK_VERSION(0, 2, 0)
+                                         XB_BUILDER_SOURCE_FLAG_WATCH_DIRECTORY,
+#else
                                          XB_BUILDER_SOURCE_FLAG_WATCH_FILE,
+#endif
                                          cancellable,
                                          error)) {
                return FALSE;
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 3abb25a7..020f821e 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -636,7 +636,11 @@ gs_flatpak_load_desktop_fn (GsFlatpak *self,
 
        /* add source */
        if (!xb_builder_source_load_file (source, file,
+#if LIBXMLB_CHECK_VERSION(0, 2, 0)
+                                         XB_BUILDER_SOURCE_FLAG_WATCH_DIRECTORY,
+#else
                                          XB_BUILDER_SOURCE_FLAG_WATCH_FILE,
+#endif
                                          cancellable,
                                          error)) {
                return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]