Commits

Sebastian Sdorra committed 0aa7cf6

remove empty directory after failed repository creation

  • Participants
  • Parent commits 975895c
  • Branches issue-106

Comments (0)

Files changed (1)

File scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java

 
 //~--- non-JDK imports --------------------------------------------------------
 
+import com.google.common.base.Throwables;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
     }
 
     checkPath(directory);
-    fileSystem.create(directory);
-    create(repository, directory);
-    postCreate(repository, directory);
+
+    try
+    {
+      fileSystem.create(directory);
+      create(repository, directory);
+      postCreate(repository, directory);
+    }
+    catch (Exception ex)
+    {
+      if (directory.exists())
+      {
+        if (logger.isDebugEnabled())
+        {
+          logger.debug(
+              "delete repository directory {}, because of failed repository creation",
+              directory);
+        }
+
+        fileSystem.destroy(directory);
+      }
+
+      Throwables.propagateIfPossible(ex, RepositoryException.class,
+                                     IOException.class);
+    }
   }
 
   /**