summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2020-05-11 10:41:34 +0000
committerSam Thursfield <sam@afuera.me.uk>2020-05-11 10:41:34 +0000
commita6e0f8af460a753358c34baacfa8cbfa36c9f706 (patch)
tree15154222c53da71e7220d9a922d6ee6790c2cf27
parent0e544c343ecd0bf121018b2e358bb6a8aed7ccf4 (diff)
parent240d70f83f1d8945c592f7f33c0c02b9782a3131 (diff)
downloadtracker-a6e0f8af460a753358c34baacfa8cbfa36c9f706.tar.gz
Merge branch 'sam/sandbox-session-dirs' into 'master'
tracker-sandbox: Add `--use-session-dirs` option See merge request GNOME/tracker!243
-rw-r--r--utils/trackertestutils/__main__.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/utils/trackertestutils/__main__.py b/utils/trackertestutils/__main__.py
index abfec5f2c..eb75279a9 100644
--- a/utils/trackertestutils/__main__.py
+++ b/utils/trackertestutils/__main__.py
@@ -83,17 +83,18 @@ def environment_set_and_add_path(env, var, prefix, suffix):
env[var] = full
-def create_sandbox(store_location, prefix=None, dbus_config=None,
- interactive=False):
+def create_sandbox(store_location, prefix=None, use_session_dirs=False,
+ dbus_config=None, interactive=False):
assert prefix is None or dbus_config is None
extra_env = {}
# Data
- extra_env['XDG_DATA_HOME'] = '%s/data/' % store_location
- extra_env['XDG_CONFIG_HOME'] = '%s/config/' % store_location
- extra_env['XDG_CACHE_HOME'] = '%s/cache/' % store_location
- extra_env['XDG_RUNTIME_DIR'] = '%s/run/' % store_location
+ if not use_session_dirs:
+ extra_env['XDG_DATA_HOME'] = '%s/data/' % store_location
+ extra_env['XDG_CONFIG_HOME'] = '%s/config/' % store_location
+ extra_env['XDG_CACHE_HOME'] = '%s/cache/' % store_location
+ extra_env['XDG_RUNTIME_DIR'] = '%s/run/' % store_location
# Prefix - only set if non-standard
if prefix and prefix != '/usr':
@@ -190,6 +191,8 @@ def argument_parser():
parser.add_argument('-s', '--store', metavar='DIR', action=expand_path,
default=default_store_location, dest='store_location',
help=f"directory to store the index (default={default_store_location})")
+ parser.add_argument('--use-session-dirs', action='store_true',
+ help=f"update the real Tracker index (use with care!)")
parser.add_argument('--store-tmpdir', action='store_true',
help="create index in a temporary directory and "
"delete it on exit (useful for automated testing)")
@@ -348,15 +351,22 @@ def main():
raise RuntimeError("--wait-for-miner cannot be used when opening an "
"interactive shell.")
+ use_session_dirs = False
store_location = None
store_tmpdir = None
- if args.store_location != default_store_location and args.store_tmpdir:
- raise RuntimeError("The --store-tmpdir flag is enabled, but --store= was also passed.")
- if args.store_tmpdir:
- store_location = store_tmpdir = tempfile.mkdtemp(prefix='tracker-sandbox-store')
+ if args.use_session_dirs:
+ if args.store_location != default_store_location or args.store_tmpdir:
+ raise RuntimeError("The --use-session-dirs flag cannot be combined "
+ " with --store= or --store-tmpdir")
+ use_session_dirs = True
else:
- store_location = args.store_location
+ if args.store_location != default_store_location and args.store_tmpdir:
+ raise RuntimeError("The --store-tmpdir flag is enabled, but --store= was also passed.")
+ if args.store_tmpdir:
+ store_location = store_tmpdir = tempfile.mkdtemp(prefix='tracker-sandbox-store')
+ else:
+ store_location = args.store_location
index_recursive_directories = None
index_recursive_tmpdir = None
@@ -376,11 +386,13 @@ def main():
# Set up environment variables and foo needed to get started.
sandbox = create_sandbox(store_location, args.prefix,
+ use_session_dirs=use_session_dirs,
dbus_config=args.dbus_config,
interactive=interactive)
config_set(sandbox, index_recursive_directories)
- link_to_mime_data()
+ if not use_session_dirs:
+ link_to_mime_data()
miner_watches = {}
for miner in (args.wait_for_miner or []):