Commit 5b503021 authored by Adrian Rossouw's avatar Adrian Rossouw

Clean up symlink iteration and support symlinks on import #267592

parent db9e99f4
......@@ -22,8 +22,12 @@ function drush_provision_drupal_post_provision_import() {
if (d()->type === 'site') {
d()->profile = drush_get_option('profile', 'default', 'site');
d()->language = drush_get_option('language', 'en', 'site');
d()->aliases = drush_set_option('aliases', provision_drupal_find_aliases());
d()->write_alias();
// set this in the site options too so it recurrs.
drush_set_option('aliases', drush_get_option('aliases'), 'site');
provision_backend_invoke(d()->name, 'provision-verify');
}
}
......
......@@ -290,6 +290,32 @@ function provision_drupal_find_sites() {
return $sites;
}
/**
* Retrieve a list of aliases for the curent site.
*/
function provision_drupal_find_aliases() {
$aliases = array();
if (d()->type === 'site') {
if ($dir = opendir(d()->root . "/sites")) {
while (FALSE !== ($subdir = readdir($dir))) {
// skip internal directory pointers
if ($subdir != '.' && $subdir != '..') {
$path = d()->root . '/sites/' . $subdir;
if (is_link($path)) {
if (d()->uri === readlink($path)) {
$aliases[] = $subdir;
}
}
}
}
closedir($dir);
}
}
return $aliases;
}
function _provision_drupal_get_cvs_versions($files) {
foreach ($files as $modulename => $file) {
$project = array();
......@@ -332,29 +358,16 @@ function _provision_drupal_maintain_aliases() {
* Delete a list of aliases
*/
function _provision_drupal_delete_aliases() {
$aliases = array();
if (d()->type === 'site') {
if ($dir = opendir(d()->root . "/sites")) {
while (FALSE !== ($subdir = readdir($dir))) {
// skip internal directory pointers
if ($subdir != '.' && $subdir != '..') {
$path = d()->root . '/sites/' . $subdir;
if (is_link($path)) {
if (d()->uri === readlink($path)) {
$aliases[] = $path;
}
}
}
}
closedir($dir);
foreach ($aliases as $alias) {
provision_file()->unlink($alias)
->succeed('Removed symlink for alias @path')
->fail('Could not remove symlink for alias @path');
d()->service('http')->sync($alias);
}
if (d()->type === 'site') {
$aliases = provision_drupal_find_aliases();
foreach ($aliases as $alias) {
$path = d()->root . '/sites/' . $alias;
provision_file()->unlink($path)
->succeed('Removed symlink for alias @path')
->fail('Could not remove symlink for alias @path');
d()->service('http')->sync($path);
}
}
}
......
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