- Patch #511760 by rfay: improve the error messages in file_unmanaged_copy().
parent
d6ce954260
commit
a86654f876
|
@ -445,19 +445,22 @@ function file_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME)
|
|||
* @see file_copy()
|
||||
*/
|
||||
function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
|
||||
$original_source = $source;
|
||||
$original_destination = $destination;
|
||||
|
||||
$source = realpath($source);
|
||||
if (!file_exists($source)) {
|
||||
drupal_set_message(t('The specified file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $source)), 'error');
|
||||
drupal_set_message(t('The specified file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$destination = file_create_path($destination);
|
||||
$directory = $destination;
|
||||
$proposed_destination = file_create_path($destination);
|
||||
$directory = $proposed_destination;
|
||||
$basename = file_check_path($directory);
|
||||
|
||||
// Make sure we at least have a valid directory.
|
||||
if ($basename === FALSE) {
|
||||
drupal_set_message(t('The specified file %file could not be copied, because the destination %directory is not properly configured.', array('%file' => $source, '%directory' => $destination)), 'error');
|
||||
drupal_set_message(t('The specified file %file could not be copied, because the destination %directory is not properly configured. This is often caused by a problem with file or directory permissions.', array('%file' => $original_source, '%directory' => empty($original_destination) ? $proposed_destination : $original_destination)), 'error');
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -467,7 +470,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
|
|||
$destination = file_destination($directory . '/' . $basename, $replace);
|
||||
|
||||
if ($destination === FALSE) {
|
||||
drupal_set_message(t('The specified file %file could not be copied because a file by that name already exists in the destination.', array('%file' => $source)), 'error');
|
||||
drupal_set_message(t('The specified file %file could not be copied because a file by that name already exists in the destination %directory.', array('%file' => $source, '%directory' => $proposed_destination)), 'error');
|
||||
return FALSE;
|
||||
}
|
||||
// Make sure source and destination filenames are not the same, makes no
|
||||
|
|
Loading…
Reference in New Issue