From 4e9afd1a8bb6617779dbdb1cb8dd48bcb4c91ce8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@koumbit.org>
Date: Thu, 10 Dec 2009 13:22:44 -0500
Subject: [PATCH] #597738 - don't install over already installed sites

we do it the proper way, by using site_exists(), not site_installed()
---
 db_server/install.provision.inc |  4 +++-
 platform/install.provision.inc  | 12 ++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/db_server/install.provision.inc b/db_server/install.provision.inc
index 7c48ed289..686c88b80 100644
--- a/db_server/install.provision.inc
+++ b/db_server/install.provision.inc
@@ -15,5 +15,7 @@ function drush_provision_mysql_pre_provision_install($url = NULL) {
 }
 
 function drush_provision_mysql_pre_provision_install_rollback($url = NULL) {
-  _provision_mysql_destroy_site_db(drush_get_option('db_name'), drush_get_option('db_user'), drush_get_option('db_passwd'));
+  if (!_provision_drupal_site_installed($url)) {
+    _provision_mysql_destroy_site_db(drush_get_option('db_name'), drush_get_option('db_user'), drush_get_option('db_passwd'));
+  }
 }
diff --git a/platform/install.provision.inc b/platform/install.provision.inc
index f8fd7d8e4..abc6b218e 100644
--- a/platform/install.provision.inc
+++ b/platform/install.provision.inc
@@ -18,8 +18,8 @@ function drush_provision_drupal_provision_install_validate($url) {
   if (!$url) {
     return drush_set_error("PROVISION_URL_REQUIRED", dt("You need to specify a valid url to install a site"));
   }
-  if (drush_get_option('installed')) {
-    drush_set_error('PROVISION_SITE_INSTALLED');
+  if (_provision_drupal_site_exists($url)) {
+    return drush_set_error('PROVISION_SITE_INSTALLED');
   }
 }
 
@@ -52,12 +52,12 @@ function drush_provision_drupal_provision_install($url) {
  * If the install went south, and the site is not PROVISION_SITE_INSTALLED, clean up behind ourselves
  */
 function drush_provision_drupal_provision_install_rollback($url) {
-  if (!drush_cmp_error('PROVISION_SITE_INSTALLED')) {
-    if ($url) {
+  if ($url) {
+    if (!_provision_drupal_site_installed($url)) {
       _provision_recursive_delete("sites/$url");
-    } else {
-      drush_set_error('PROVISION_FRAMEWORK_ERROR', dt('no url defined in %function', array('%function' => __FUNCTION__)));
     }
+  } else {
+    drush_set_error('PROVISION_FRAMEWORK_ERROR', dt('no url defined in %function', array('%function' => __FUNCTION__)));
   }
 }
 
-- 
GitLab