shaarli: Completely uninstall app

* remove data directory when app is uninstalled

Tests:
1. Install and configure the app
2. Reinstall app and confirm the initial setup page is shown

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Update docstrings, make uninstall fail-safe]
[sunil: Fix uninstall test by setting up after reinstall]
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:03:27 +02:00 committed by Sunil Mohan Adapa
parent be7fd45393
commit 6ab0be6f9a
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 23 additions and 1 deletions

View File

@ -12,7 +12,7 @@ from plinth.modules.backups.components import BackupRestore
from plinth.modules.firewall.components import Firewall
from plinth.package import Packages
from . import manifest
from . import manifest, privileged
_description = [
_('Shaarli allows you to save and share bookmarks.'),
@ -69,3 +69,8 @@ class ShaarliApp(app_module.App):
"""Install and configure the app."""
super().setup(old_version)
self.enable()
def uninstall(self):
"""De-configure and uninstall the app."""
super().uninstall()
privileged.uninstall()

View File

@ -0,0 +1,12 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Configure Shaarli."""
import shutil
from plinth.actions import privileged
@privileged
def uninstall():
"""Remove Shaarli's data directory."""
shutil.rmtree('/var/lib/shaarli/data', ignore_errors=True)

View File

@ -74,3 +74,8 @@ class TestShaarliApp(functional.BaseAppTests):
assert len(links) > 0
# TODO: Test deleting bookmarks.
def test_uninstall(self, session_browser):
"""After uninstall test, after installing run initial setup."""
super().test_uninstall(session_browser)
self._shaarli_is_setup(session_browser)