gitweb: Completely uninstall app, remove repositories

Tests:
1. Install app, create a repository
2. Reinstall app and confirm the repository is removed

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Update docstrings, make uninstall fail-safe]
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 00:17:33 +02:00 committed by Sunil Mohan Adapa
parent 615c47e49f
commit 53f4edb016
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 13 additions and 0 deletions

View File

@ -127,6 +127,11 @@ class GitwebApp(app_module.App):
privileged.setup()
self.enable()
def uninstall(self):
"""De-configure and uninstall the app."""
super().uninstall()
privileged.uninstall()
class GitwebWebserverAuth(Webserver):
"""Component to handle Gitweb authentication webserver configuration."""

View File

@ -4,6 +4,7 @@
import configparser
import logging
import os
import pathlib
import re
import shutil
import subprocess
@ -386,3 +387,10 @@ def delete_repo(name: str):
repo = validate_repo_name(name)
repo_path = os.path.join(GIT_REPO_PATH, repo)
shutil.rmtree(repo_path)
@privileged
def uninstall():
"""Remove git repositories."""
for item in pathlib.Path(GIT_REPO_PATH).glob('*'):
shutil.rmtree(item, ignore_errors=True)