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 <contact@nbenedek.me>
[sunil: Update docstrings, make uninstall fail-safe]
[sunil: Remove the entire configuration directory]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
nbenedek 2023-04-07 03:26:49 +02:00 committed by Sunil Mohan Adapa
parent 77318806c2
commit f1d2139c2d
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 12 additions and 0 deletions

View File

@ -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()

View File

@ -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)