diff --git a/commands/make/make.drush.inc b/commands/make/make.drush.inc index 7ddc41b..cede560 100644 --- a/commands/make/make.drush.inc +++ b/commands/make/make.drush.inc @@ -509,7 +509,11 @@ function make_move_build($build_path) { // TODO: This only protects one level of directories from being removed. $files = drush_scan_directory($file->filename, '/./', array('.', '..'), 0, FALSE); foreach ($files as $file) { - $ret = $ret && drush_copy_dir($file->filename, $destination . DIRECTORY_SEPARATOR . $file->basename, TRUE); + #$ret = $ret && drush_copy_dir($file->filename, $destination . DIRECTORY_SEPARATOR . $file->basename, TRUE); + # drush_copy_dir will delete code in existing installs. + # http://drupal.org/node/1539076 + # Extend the $overwrite flag to offer a 'merge' option. + $ret = $ret && drush_copy_dir($file->filename, $destination . DIRECTORY_SEPARATOR . $file->basename, 'FILE_EXISTS_MERGE'); } } else { diff --git a/includes/filesystem.inc b/includes/filesystem.inc index 7b049c4..f00e5dd 100644 --- a/includes/filesystem.inc +++ b/includes/filesystem.inc @@ -159,18 +159,25 @@ function drush_delete_tmp_dir($dir) { * it to "d", then $dest = "/c/d". * @param $overwrite * If TRUE, the destination will be deleted if it exists. + * If neither TRUE or FALSE, try to merge instead. (needs work) + * http://drupal.org/node/1539076 * @return * TRUE on success, FALSE on failure. */ function drush_copy_dir($src, $dest, $overwrite = FALSE) { // Preflight based on $overwrite if $dest exists. if (file_exists($dest)) { - if ($overwrite) { + if ($overwrite === TRUE) { drush_op('drush_delete_dir', $dest, TRUE); } - else { + elseif ($overwrite === FALSE) { return drush_set_error('DRUSH_DESTINATION_EXISTS', dt('Destination directory !dest already exists.', array('!dest' => $dest))); } + elseif ($overwrite == 'FILE_EXISTS_MERGE') { + // $overwrite flag may indicate we should merge instead. + // That's OK to just continue. + drush_log('Merging, not overwriting'); + } } // $src readable? if (!is_readable($src)) {