From f1d2139c2ddbcc5f8ffb3279eb0c363c47cd4b3a Mon Sep 17 00:00:00 2001 From: nbenedek Date: Fri, 7 Apr 2023 03:26:49 +0200 Subject: [PATCH] syncthing: Completely uninstall app Remove config file when app is uninstalled Tests: 1. Install app and add a share 2. Reinstall app and confirm that the share doesn't exist The order of the functional tests should be modified since 'test_add_remove_folder' fails Signed-off-by: nbenedek [sunil: Update docstrings, make uninstall fail-safe] [sunil: Remove the entire configuration directory] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/syncthing/__init__.py | 5 +++++ plinth/modules/syncthing/privileged.py | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/plinth/modules/syncthing/__init__.py b/plinth/modules/syncthing/__init__.py index 4fb74dc95..4b1b4402b 100644 --- a/plinth/modules/syncthing/__init__.py +++ b/plinth/modules/syncthing/__init__.py @@ -143,3 +143,8 @@ class SyncthingApp(app_module.App): sharing.remove_share(name) sharing.add_share(name, share['path'], new_groups, share['is_public']) + + def uninstall(self): + """De-configure and uninstall the app.""" + super().uninstall() + privileged.uninstall() diff --git a/plinth/modules/syncthing/privileged.py b/plinth/modules/syncthing/privileged.py index efa8c40f7..e3b70cb65 100644 --- a/plinth/modules/syncthing/privileged.py +++ b/plinth/modules/syncthing/privileged.py @@ -3,6 +3,7 @@ import grp import os +import pathlib import pwd import shutil import subprocess @@ -80,3 +81,9 @@ def setup_config(): if conf_changed: action_utils.service_try_restart('syncthing@syncthing') + + +@privileged +def uninstall(): + """Remove configuration file when app is uninstalled.""" + shutil.rmtree(DATA_DIR + '/.config', ignore_errors=True)