diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2016-06-13 16:28:30 +0100 |
---|---|---|
committer | Sam Thursfield <ssssam@gmail.com> | 2016-06-25 12:54:35 +0100 |
commit | 8a758a03afadae65e734f660d1540289e1deb096 (patch) | |
tree | 9ee41e20ed23e1051f4d7cc4c099835fc992cc14 | |
parent | e460bbc172a3c822bf2b3fc63340186ae19eef5c (diff) | |
download | tracker-8a758a03afadae65e734f660d1540289e1deb096.tar.gz |
sandbox: Fix MIME-type detection inside the sandbox
It turns out that MIME-type detection depends on various files in
$XDG_DATA_HOME/mime, at least on my Fedora 24 system.
We need to link to these files in our overridden XDG_DATA_HOME dir if we
want extraction to work properly, otherwise everything is detected as
text/plain.
-rwxr-xr-x | utils/sandbox/tracker-sandbox.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/utils/sandbox/tracker-sandbox.py b/utils/sandbox/tracker-sandbox.py index 42d0e333a..abfb05be8 100755 --- a/utils/sandbox/tracker-sandbox.py +++ b/utils/sandbox/tracker-sandbox.py @@ -78,6 +78,8 @@ dbus_session_file = '' store_pid = -1 store_proc = None +original_xdg_data_home = GLib.get_user_data_dir() + # Template config file config_template = """ [General] @@ -399,6 +401,22 @@ def config_set(): config.write(f) +def link_to_mime_data(): + '''Create symlink to $XDG_DATA_HOME/mime in our custom data home dir. + + Mimetype detection seems to break horribly if the $XDG_DATA_HOME/mime + directory is missing. Since we have to override the normal XDG_DATA_HOME + path, we need to work around this by linking back to the real mime data. + + ''' + new_xdg_data_home = os.environ['XDG_DATA_HOME'] + new_mime_dir = os.path.join(new_xdg_data_home, 'mime') + if not os.path.exists(new_mime_dir): + mkdir_p(new_xdg_data_home) + os.symlink( + os.path.join(original_xdg_data_home, 'mime'), new_mime_dir) + + # Entry point/start if __name__ == "__main__": locale.setlocale(locale.LC_ALL, '') @@ -493,6 +511,8 @@ if __name__ == "__main__": environment_set() config_set() + link_to_mime_data() + try: if opts.update: index_update() |