From b0b076d52a6e4ede3fe50b4ab86910ac66583dce Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 26 Aug 2019 09:06:12 +1000 Subject: [PATCH] config: don't purge drawings We used to drop all but the last 10 drawings on startup and as the comment says so that users don't rely on tuhi for storage. That's mostly fine when Tuhi is a separate daemon but now the primary interface is the GUI. So we can run into this situation: - user starts Tuhi (which in turn starts tuhi-gui and tuhi-server) - tuhi-server downloads 20 fresh drawings from the device - tuhi-gui crashes before it can fetch them from the tuhi-server - restart Tuhi, the server now purges 10 out of those 20 drawings that the user has never seen. They're gone for good. Let's drop that code until we figure out a better solution to that (e.g. drop drawings older than X months but that too is fraught with errors). Signed-off-by: Peter Hutterer --- tuhi/config.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tuhi/config.py b/tuhi/config.py index 827a0a2..bee8809 100644 --- a/tuhi/config.py +++ b/tuhi/config.py @@ -69,8 +69,6 @@ class TuhiConfig(GObject.Object): config = configparser.ConfigParser() config.read(settings) - self._purge_drawings(directory) - btaddr = directory.name assert config['Device']['Address'] == btaddr if 'Protocol' not in config['Device']: @@ -131,19 +129,6 @@ class TuhiConfig(GObject.Object): configdir = Path(self._base_path, address) return [Drawing.from_json(f) for f in configdir.glob('*.json')] - def _purge_drawings(self, directory): - '''Removes all but the most recent 10 files from the config - directory. This is primarily done so that no-one relies on the tuhi - daemon for permanent storage.''' - - files = [x for x in Path(directory).glob('*.json')] - - if len(files) > 10: - files.sort(key=lambda e: e.name) - for f in files[:-10]: - logger.debug(f'{directory.name}: purging {f.name}') - f.unlink() - @classmethod def set_base_path(cls, path): if cls._instance is not None: