# HG changeset patch # User Goffi # Date 1580845637 -3600 # Node ID eb3f622d87912b4751b0a61ab7b240572affd3ba # Parent 9d3481663964b0e70d3df9cd865a98e2938483df android: create/clean a temporary directory on startup: directory returned by tempfiles on Android is actually the root directory of the application, so it is not cleaned. To work around that a `/tmp` directory inside it is now created, and cleaned on startup if it already exists. diff -r 9d3481663964 -r eb3f622d8791 cagou/core/cagou_main.py --- a/cagou/core/cagou_main.py Tue Feb 04 20:47:17 2020 +0100 +++ b/cagou/core/cagou_main.py Tue Feb 04 20:47:17 2020 +0100 @@ -462,6 +462,9 @@ resync() self.contact_lists.fill() + def getConfig(self, section, name, default=None): + return config.getConfig(main_config, section, name, default) + def onBridgeConnected(self): super(Cagou, self).onBridgeConnected() self.registerSignal("otrState", iface="plugin") diff -r 9d3481663964 -r eb3f622d8791 cagou/core/platform_/android.py --- a/cagou/core/platform_/android.py Tue Feb 04 20:47:17 2020 +0100 +++ b/cagou/core/platform_/android.py Tue Feb 04 20:47:17 2020 +0100 @@ -22,6 +22,8 @@ import json from functools import partial from urllib.parse import urlparse +from pathlib import Path +import shutil from jnius import autoclass, cast from android import activity from sat.core.i18n import _ @@ -77,6 +79,15 @@ activity.bind(on_new_intent=self.on_new_intent) self.cache.append((self.on_new_intent, mActivity.getIntent())) host.addListener('profilePlugged', self.onProfilePlugged) + local_dir = Path(host.getConfig('', 'local_dir')).resolve() + self.tmp_dir = local_dir / 'tmp' + # we assert to avoid disaster if `/ 'tmp'` is removed by mistake on the line + # above + assert self.tmp_dir.resolve() != local_dir + # we reset tmp dir on each run, to be sure that there is no residual file + if self.tmp_dir.exists(): + shutil.rmtree(self.tmp_dir) + self.tmp_dir.mkdir(0o700) def on_initFrontendState(self): # XXX: we use a separated socket instead of bridge because if we