Commit 3b6f4a35 authored by drumm's avatar drumm Committed by Neil Drumm

Clean up site delete

parent 72471e28
...@@ -13,15 +13,28 @@ class provisionService_file_remote extends provisionService_file { ...@@ -13,15 +13,28 @@ class provisionService_file_remote extends provisionService_file {
$path = $this->config_path; $path = $this->config_path;
} }
$options = array( if ($this->exists($path)->status()) {
'delete' => TRUE, $options = array(
'exclude-sites' => $exclude_sites, 'relative' => TRUE,
); 'delete' => TRUE,
if (drush_core_call_rsync(escapeshellarg($path . '/'), escapeshellarg($this->script_user . '@' . $this->remote_host . ':' . $path), $options)) { );
drush_log(dt('@path has been synced to remote server.', array('@path' => $path))); if ($exclude_sites) {
$options['exclude-sites'] = TRUE;
}
if (drush_core_call_rsync(escapeshellarg($path), escapeshellarg($this->script_user . '@' . $this->remote_host . ':/'), $options)) {
drush_log(dt('@path has been synced to remote server.', array('@path' => $path)));
}
else {
drush_set_error('PROVISION_FILE_SYNC_FAILED', dt('Files could not be synced to remote server. Changes might not be available until this has been done. (error: %msg)', array('@path' => $path, '%msg' => join("\n", drush_shell_exec_output()))));
}
} }
else { else { // File does not exist, remove it.
drush_set_error('PROVISION_FILE_SYNC_FAILED', dt('Files could not be synced to remote server. Changes might not be available until this has been done. (error: %msg)', array('@path' => $path, '%msg' => join("\n", drush_shell_exec_output())))); if ($this->server()->shell_exec('rm -rf ' . escapeshellarg($path))) {
drush_log(dt('@path has been removed from remote server.', array('@path' => $path)));
}
else {
drush_set_error('PROVISION_FILE_SYNC_FAILED', dt('Files could not be removed from remote server. Changes might not be available until this has been done. (error: %msg)', array('@path' => $path, '%msg' => join("\n", drush_shell_exec_output()))));
}
} }
} }
} }
...@@ -21,12 +21,12 @@ class provisionService_http_apache extends provisionService_http { ...@@ -21,12 +21,12 @@ class provisionService_http_apache extends provisionService_http {
function create_site_config() { function create_site_config() {
$config = new provisionConfig_apache_site($this->context, drush_get_context('site')); $config = new provisionConfig_apache_site($this->context, drush_get_context('site'));
return $config->write(); $config->write();
} }
function delete_site_config() { function delete_site_config() {
$config = new provisionConfig_apache_site($this->context); $config = new provisionConfig_apache_site($this->context);
return $config->unlink(); $config->unlink();
} }
function create_platform_config() { function create_platform_config() {
...@@ -36,7 +36,7 @@ class provisionService_http_apache extends provisionService_http { ...@@ -36,7 +36,7 @@ class provisionService_http_apache extends provisionService_http {
function delete_platform_config() { function delete_platform_config() {
$config = new provisionConfig_apache_platform($this->context); $config = new provisionConfig_apache_platform($this->context);
return $config->unlink(); $config->unlink();
} }
function create_server_config() { function create_server_config() {
...@@ -47,7 +47,7 @@ class provisionService_http_apache extends provisionService_http { ...@@ -47,7 +47,7 @@ class provisionService_http_apache extends provisionService_http {
function delete_server_config() { function delete_server_config() {
$config = new provisionConfig_apache_server($this->context); $config = new provisionConfig_apache_server($this->context);
return $config->unlink(); $config->unlink();
} }
function verify() { function verify() {
...@@ -73,7 +73,6 @@ class provisionService_http_apache extends provisionService_http { ...@@ -73,7 +73,6 @@ class provisionService_http_apache extends provisionService_http {
} }
function parse_configs() { function parse_configs() {
d()->service('file')->sync();
// This is required to be configurable, due to the fact that different // This is required to be configurable, due to the fact that different
// hosts might need to do this differently. // hosts might need to do this differently.
if (d()->service('http')->server()->shell_exec($this->restart_cmd)) { if (d()->service('http')->server()->shell_exec($this->restart_cmd)) {
......
...@@ -26,19 +26,19 @@ function drush_provision_drupal_pre_provision_delete($backup_file = NULL) { ...@@ -26,19 +26,19 @@ function drush_provision_drupal_pre_provision_delete($backup_file = NULL) {
function drush_provision_drupal_provision_delete() { function drush_provision_drupal_provision_delete() {
if (d()->type === 'site') { if (d()->type === 'site') {
_provision_recursive_delete(d()->root . '/sites/' . d()->uri); _provision_recursive_delete(d()->root . '/sites/' . d()->uri);
d()->service('file')->sync(d()->root . '/sites/' . d()->uri);
// we remove the aliases even if redirection is enabled as a precaution // we remove the aliases even if redirection is enabled as a precaution
// if redirection is enabled, keep silent about errors // if redirection is enabled, keep silent about errors
_provision_drupal_delete_aliases(drush_get_option('aliases', array(), 'site'), drush_get_option('redirection')); _provision_drupal_delete_aliases(drush_get_option('aliases', array(), 'site'), drush_get_option('redirection'));
drush_set_option('installed', FALSE, 'site'); drush_set_option('installed', FALSE, 'site');
} }
if (d()->type === 'platform') { if (d()->type === 'platform') {
$sites = provision_drupal_find_sites(); if (provision_drupal_find_sites()) {
if($sites) {
drush_set_error(dt('Existing sites were found on this platform. These sites will need to be deleted before this platform can be deleted.')); drush_set_error(dt('Existing sites were found on this platform. These sites will need to be deleted before this platform can be deleted.'));
} }
else { else {
$drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'); _provision_recursive_delete(d()->root);
_provision_recursive_delete($drupal_root); d()->service('file')->sync(d()->root);
} }
} }
} }
......
...@@ -113,12 +113,14 @@ class provisionConfig { ...@@ -113,12 +113,14 @@ class provisionConfig {
->succeed('Change group ownership of @path to @gid') ->succeed('Change group ownership of @path to @gid')
->fail('Could not change group ownership of @path to @gid'); ->fail('Could not change group ownership of @path to @gid');
} }
d()->service('file')->sync($this->filename());
} }
} }
} }
function unlink() { function unlink() {
return d()->service('file')->unlink($this->filename())->status(); d()->service('file')->unlink($this->filename())->status();
d()->service('file')->sync($this->filename());
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment