[tracker-miners/wip/hadess/domain: 2/2] data: Make default indexed dirs configurable




commit d71e433f6a7d7cc4a8da86a8300e8294d83c4a47
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Aug 28 14:40:05 2020 +0200

    data: Make default indexed dirs configurable
    
    Add index_recursive_dirs and index_single_dirs meson options to allow
    passing which directories should be indexed by default. This makes it
    easier for sandboxed applications which use Tracker 3 inside the sandbox
    to change the directories they want indexed.

 data/meson.build                                     | 20 +++++++++++++++++++-
 data/org.freedesktop.Tracker.Miner.Files.gschema.xml |  4 ++--
 meson_options.txt                                    |  6 ++++++
 3 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index b3fa6dd70..6c25bd5c8 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -4,13 +4,31 @@ schemas = {
   'org.freedesktop.Tracker.Miner.Files.gschema.xml': 'org.freedesktop.Tracker@0  Miner Files gschema 
xml'.format(tracker_api_major),
 }
 
+dir_conf = configuration_data()
+
+dirs = {
+  'default_index_recursive_dirs': 'INDEX_RECURSIVE_DIRS',
+  'default_index_single_dirs': 'INDEX_SINGLE_DIRS'
+}
+foreach opt_name, variable : dirs
+  array = []
+  foreach dir : get_option(opt_name)
+    # See https://github.com/mesonbuild/meson/issues/4007
+    escaped_dir = '&amp;'.join(dir.split('&'))
+    array += [ '\'' + escaped_dir + '\'' ]
+  endforeach
+  # Remove the trailing comma
+  str = ', '.join(array)
+  dir_conf.set(variable, str)
+endforeach
+
 schemas_file_deps = []
 foreach source, dest : schemas
     configure_file(
         input: source,
         output: dest,
-        copy: true,
         install: true,
+        configuration: dir_conf,
         install_dir: gsettings_schema_dir)
     schemas_file_deps += source
 endforeach
diff --git a/data/org.freedesktop.Tracker.Miner.Files.gschema.xml 
b/data/org.freedesktop.Tracker.Miner.Files.gschema.xml
index 30f1c6e1c..dd4a106a6 100644
--- a/data/org.freedesktop.Tracker.Miner.Files.gschema.xml
+++ b/data/org.freedesktop.Tracker.Miner.Files.gschema.xml
@@ -106,7 +106,7 @@ Boston, MA  02110-1301, USA.
 
        See /etc/xdg/user-dirs.defaults and $HOME/.config/user-dirs.default
       </description>
-      <default>[ '&amp;DESKTOP', '&amp;DOCUMENTS', '&amp;MUSIC', '&amp;PICTURES', '&amp;VIDEOS' ]</default>
+      <default>[ @INDEX_RECURSIVE_DIRS@ ]</default>
     </key>
 
     <key name="index-single-directories" type="as">
@@ -120,7 +120,7 @@ Boston, MA  02110-1301, USA.
 
        See /etc/xdg/user-dirs.defaults and $HOME/.config/user-dirs.default
       </description>
-      <default>[ '$HOME', '&amp;DOWNLOAD' ]</default>
+      <default>[ @INDEX_SINGLE_DIRS@ ]</default>
     </key>
 
     <key name="index-applications" type="b">
diff --git a/meson_options.txt b/meson_options.txt
index be2881e3a..3420973ab 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -19,6 +19,12 @@ option('domain_prefix', type: 'string', value: 'org.freedesktop',
        description: 'Domain prefix to use, useful for sandboxing')
 option('miner_fs_cache_location', type: 'string', value: '',
        description: 'Location of the miner cache, only used when domain_prefix is not \'org.freedesktop\'')
+option('default_index_recursive_dirs', type: 'array',
+       value: [ '&DESKTOP', '&DOCUMENTS', '&MUSIC', '&PICTURES', '&VIDEOS' ],
+       description: 'List of directories to index recursively')
+option('default_index_single_dirs', type: 'array',
+       value: [ '$HOME', '&DOWNLOAD' ],
+       description: 'List of directories to index without inspecting subfolders')
 
 option('network_manager', type: 'feature', value: 'auto',
        description: 'Connection detection through NetworkManager')


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