From 0c7b302712c5ad3b1e261abbabeed552d7e188a1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 27 2014 08:15:02 +0000 Subject: When deleting a project/fork, clean the git repos on the filesystem as well --- diff --git a/progit/repo.py b/progit/repo.py index b6fd6f7..4a673f2 100644 --- a/progit/repo.py +++ b/progit/repo.py @@ -9,6 +9,7 @@ """ import flask +import shutil import os from math import ceil @@ -490,8 +491,18 @@ def delete_repo(repo, username=None): SESSION.delete(request) SESSION.delete(repo) + repopath = os.path.join(APP.config['GIT_FOLDER'], repo.path) + if repo.is_fork: + repopath = os.path.join(APP.config['FORK_FOLDER'], repo.path) + docpath = os.path.join(APP.config['DOCS_FOLDER'], repo.path) + try: + shutil.rmtree(repopath) + shutil.rmtree(docpath) SESSION.commit() + except (OSError, IOError), err: + APP.logger.exception(err) + flask.flash('Could not delete the project from the system', 'error') except SQLAlchemyError, err: # pragma: no cover SESSION.rollback() APP.logger.exception(err)