PY-9231 Allow to create virtual env inside an empty directory
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Thu, 22 Oct 2015 12:50:14 +0000 (15:50 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Sun, 25 Oct 2015 12:49:43 +0000 (15:49 +0300)
python/src/com/jetbrains/python/sdk/AbstractCreateVirtualEnvDialog.java

index fe0d9e50fc71bbb85146bd0f54656a248d53b631..859130d11884cdde9b238382a7b2a399d64b3c01 100644 (file)
@@ -182,10 +182,14 @@ public abstract class AbstractCreateVirtualEnvDialog extends IdeaDialog {
 
   protected void checkValid() {
     final String projectName = myName.getText();
-    if (new File(getDestination()).exists()) {
-      setOKActionEnabled(false);
-      setErrorText("Directory already exists");
-      return;
+    final File destFile = new File(getDestination());
+    if (destFile.exists()) {
+      final String[] content = destFile.list();
+      if (content != null && content.length != 0) {
+        setOKActionEnabled(false);
+        setErrorText("Directory is not empty");
+        return;
+      }
     }
     if (StringUtil.isEmptyOrSpaces(projectName)) {
       setOKActionEnabled(false);
@@ -254,6 +258,7 @@ public abstract class AbstractCreateVirtualEnvDialog extends IdeaDialog {
               }
             }
           }, ModalityState.any());
+          throw new RuntimeException(e);
         }
       }