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




commit b817e25f4ce52dd7c11f85ef2742f91773d7c379
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..44ac855c6 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 = {
+  'index_recursive_dirs': 'INDEX_RECURSIVE_DIRS',
+  '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 ecb839b44..81cb597cd 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -17,6 +17,12 @@ option('writeback', type: 'boolean', value: true,
        description: 'Enable Tracker writeback feature')
 option('domain_prefix', type: 'string', value: 'org.freedesktop',
        description: 'Domain prefix to use, useful for sandboxing')
+option('index_recursive_dirs', type: 'array',
+       value: [ '&DESKTOP', '&DOCUMENTS', '&MUSIC', '&PICTURES', '&VIDEOS' ],
+       description: 'List of directories to index recursively')
+option('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]