diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php index ed28297..8a6c494 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php @@ -50,6 +50,12 @@ public function import(Row $row, array $old_destination_id_values = array()) { // already absolute. $source = $this->isTempFile($destination) ? $file : $this->configuration['source_base_path'] . $file; + $dirname = drupal_dirname($destination); + if (!file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) { + throw new MigrateException(t('Could not create directory %dirname', + array('%dirname' => $dirname))); + } + // If the start and end file is exactly the same, there is nothing to do. if (drupal_realpath($source) === drupal_realpath($destination)) { return parent::import($row, $old_destination_id_values); @@ -62,11 +68,7 @@ public function import(Row $row, array $old_destination_id_values = array()) { $replace = FILE_EXISTS_RENAME; } } - $dirname = drupal_dirname($destination); - if (!file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) { - throw new MigrateException(t('Could not create directory %dirname', - array('%dirname' => $dirname))); - } + if ($this->configuration['move']) { $copied = file_unmanaged_move($source, $destination, $replace); }