Commit 7b6dd11c authored by helmo's avatar helmo

Issue #1083366 by jmcclelland, helmo, EugenMayer, cschaub, gmania: Fixed Make...

Issue #1083366 by jmcclelland, helmo, EugenMayer, cschaub, gmania: Fixed Make the spokes authoritative for files/ and private/ directories.
parent 485c4234
......@@ -212,13 +212,25 @@ class Provision_Context_server extends Provision_Context {
*
* @param $path
* Full path to fetch.
* @param $additional_options
* An array of options that overrides whatever was passed in on the command
* line (like the 'process' context, but only for the scope of this one
* call).
*/
function fetch($path) {
function fetch($path, $additional_options = array()) {
if (!provision_is_local_host($this->remote_host)) {
if (provision_file()->exists($path)->status()) {
$options = array(
$options = array_merge(array(
'omit-dir-times' => TRUE,
);
), $additional_options);
// We need to do this due to how drush creates the rsync command.
// If the option is present at all, even if false or null, it will
// add it to the command.
if (!isset($additional_options['no-delete']) || $additional_options['no-delete'] == FALSE ) {
$options['delete'] = TRUE;
}
if (drush_core_call_rsync(escapeshellarg($this->script_user . '@' . $this->remote_host . ':/') . $path, $path, $options, TRUE, FALSE)) {
drush_log(dt('@path has been fetched from remote server @remote_host.', array(
'@path' => $path,
......
......@@ -73,6 +73,8 @@ function drush_provision_drupal_provision_backup() {
// Write the uncloaked credentials to the settings.php
_provision_drupal_create_settings_file();
provision_drupal_sync_site();
}
$olddir = getcwd();
......@@ -99,6 +101,8 @@ function drush_provision_drupal_provision_backup() {
drush_log(dt("Re-cloaking database credentials after backup"));
drush_set_option('provision_db_cloaking', TRUE);
_provision_drupal_create_settings_file();
provision_drupal_sync_site();
}
if (!$result && !drush_get_option('force', false)) {
......
......@@ -33,7 +33,7 @@ function drush_provision_drupal_provision_delete() {
// Remove the symlink in the clients directory.
_provision_client_delete_symlink();
provision_drupal_sync_site();
provision_drupal_sync_site($override_slave_authority = TRUE);
}
elseif (d()->type === 'platform') {
if (!drush_get_option('force', FALSE) && drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_ROOT) && provision_drupal_find_sites()) {
......
......@@ -84,6 +84,7 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) {
// Load the newly created information, including re-loading the new db creds.
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
_provision_drupal_create_settings_file();
provision_drupal_sync_site($override_slave_authority = TRUE);
$site_packages = drush_get_option('packages', array(), 'site');
$drupal_packages = drush_get_option('packages', array(), 'drupal');
......
......@@ -50,6 +50,7 @@ function drush_provision_drupal_provision_install() {
// Requires at least the database settings to complete.
provision_prepare_environment();
_provision_drupal_create_settings_file();
provision_drupal_sync_site();
provision_save_site_data();
......
......@@ -26,6 +26,7 @@ function drush_provision_drupal_pre_provision_migrate($platform, $new_uri = NULL
d()->site_enabled = FALSE;
_provision_drupal_create_settings_file();
drush_invoke('provision-backup');
provision_drupal_sync_site();
drush_set_option('old_platform', d()->platform->name);
......@@ -57,6 +58,8 @@ function drush_provision_drupal_pre_provision_migrate_rollback($platform, $new_u
drush_log(dt("Bringing site out of maintenance"));
d()->site_enabled = true;
_provision_drupal_create_settings_file();
provision_drupal_sync_site();
$success = provision_file()->unlink(drush_get_option('backup_file'))
->succeed('Removed unused migration site package')
->fail('Could not remove unused migration site package');
......
......@@ -94,16 +94,48 @@ function drush_provision_drupal_provision_install_backend() {
/**
* Sync the current Drupal platform and, if applicable, site. Call after
* finishing operations that affect the filesystem.
*
* @param boolean $override_slave_authority
* Overwrite e.g. the files directory on the slave.
* Useful when the master server has donw file operations, such as restoring a backup.
*/
function provision_drupal_sync_site() {
function provision_drupal_sync_site($override_slave_authority = FALSE) {
provision_file()->create_dir(d()->server->http_platforms_path, dt("Platforms"), 0755);
d()->server->sync(d()->server->http_platforms_path, array(
'exclude' => d()->server->http_platforms_path . '/*', // Make sure remote directory is created
));
// Sync the platform
d()->service('http')->sync(d()->root, array('exclude-sites' => TRUE));
if (d()->type === 'site') {
$options = array();
if ($override_slave_authority) {
$exclude = NULL;
}
else {
$exclude = 'files/*' . PATH_SEPARATOR . 'private/*';
}
// Store the current exclude-path option
$old_exclude = NULL;
if(!is_null($exclude)) {
$old_exclude = drush_get_option('exclude-paths');
drush_set_option('exclude-paths', $exclude);
}
// Sync all filesystem changes to the remote server.
d()->service('http')->sync(d()->site_path, array('no-delete' => TRUE));
d()->service('http')->sync(d()->site_path, $options);
// Reset the exclude-path option
if(!is_null($exclude)) {
if(empty($old_exclude)) {
drush_unset_option('exclude-paths');
} else {
drush_set_option('exclude-paths', $old_exclude);
}
}
}
}
......@@ -114,12 +146,14 @@ function provision_drupal_sync_site() {
* E.g. before a backup is made.
*/
function provision_drupal_sync_site_back() {
// synch filesystem changes back from the remote server.
d()->service('http')->fetch(d()->site_path . '/files/');
d()->service('http')->fetch(d()->site_path . '/private/');
d()->service('http')->fetch(d()->site_path . '/modules/');
d()->service('http')->fetch(d()->site_path . '/themes/');
d()->service('http')->fetch(d()->site_path . '/libraries/');
// Questionable... who is authoritive?
d()->service('http')->fetch(d()->site_path . '/local.settings.php');
}
......@@ -135,7 +169,6 @@ function provision_drupal_sync_site_back() {
function _provision_drupal_create_settings_file() {
$config = new Provision_Config_Drupal_Settings(d()->name, drush_get_context('site'));
$config->write();
provision_drupal_sync_site();
}
/**
......
......@@ -11,6 +11,8 @@ function drush_provision_drupal_provision_verify_validate() {
provision_prepare_environment();
_provision_drupal_create_settings_file();
provision_drupal_sync_site();
drush_errors_on();
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
}
......@@ -76,6 +78,7 @@ function drush_provision_drupal_pre_provision_verify() {
drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal');
drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
provision_drupal_sync_site();
}
elseif (d()->type === 'site') {
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
......@@ -83,7 +86,10 @@ function drush_provision_drupal_pre_provision_verify() {
_provision_drupal_create_directories();
_provision_drupal_maintain_aliases();
// Requires at least the database settings to complete.
_provision_drupal_create_settings_file();
_provision_drupal_create_settings_file();
provision_drupal_sync_site();
}
}
......
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