From 15a66494f9422d466b75865171ec1fac8363f44f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 01 2019 13:15:54 +0000 Subject: Fix deleting a project if creation failed Basically, if a project fails to be created we want to have it removed from the DB. So far, we only reverted and removed the project from the DB if the repositories were found on disk. With this commit, we'll remove the project from the DB for any exception raised. Fixes https://pagure.io/pagure/issue/4384 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index 05bbe39..fa6d06a 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -267,7 +267,7 @@ def create_project( templ, ignore_existing_repo, ) - except pagure.exceptions.RepoExistsException: + except Exception: session.delete(project) session.commit() raise