calibre: Remove libraries during uninstallation

Test:
1. Install Calibre, add a few books and libraries
2. Uninstall, then install Calibre
3. The default Library is present and empty

Signed-off-by: nbenedek <contact@nbenedek.me>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
nbenedek 2023-03-27 21:32:48 +02:00 committed by Sunil Mohan Adapa
parent b21d88419c
commit a5283771e0
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 12 additions and 1 deletions

View File

@ -16,7 +16,7 @@ from plinth.modules.users.components import UsersAndGroups
from plinth.package import Packages
from plinth.utils import format_lazy
from . import manifest
from . import manifest, privileged
_description = [
format_lazy(
@ -106,6 +106,11 @@ class CalibreApp(app_module.App):
if not old_version:
self.enable()
def uninstall(self):
"""De-configure and uninstall the app."""
super().uninstall()
privileged.uninstall()
def validate_library_name(library_name):
"""Raise exception if library name does not fit the accepted pattern."""

View File

@ -45,3 +45,9 @@ def delete_library(name: str):
library = LIBRARIES_PATH / name
shutil.rmtree(library)
action_utils.service_try_restart(calibre.CalibreApp.DAEMON)
@privileged
def uninstall():
"""Remove all libraries during uninstall."""
shutil.rmtree(LIBRARIES_PATH)