Skip to content

Commit e1b335a

Browse files
committed
add error
1 parent c2d4512 commit e1b335a

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/Core_Command.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,19 @@ function () use ( &$temp ) {
368368
$actual_temp = substr( $temp, 0, -4 ) . ".{$extension}";
369369
if ( ! rename( $temp, $actual_temp ) ) {
370370
// Fallback to copy + unlink.
371-
if ( copy( $temp, $actual_temp ) ) {
372-
$old_temp = $temp;
373-
$temp = $actual_temp;
374-
if ( ! unlink( $old_temp ) ) {
375-
register_shutdown_function(
376-
function () use ( $old_temp ) {
377-
if ( file_exists( $old_temp ) ) {
378-
unlink( $old_temp );
379-
}
371+
if ( ! copy( $temp, $actual_temp ) ) {
372+
WP_CLI::error( 'Failed to copy the downloaded file.' );
373+
}
374+
$old_temp = $temp;
375+
$temp = $actual_temp;
376+
if ( ! unlink( $old_temp ) ) {
377+
register_shutdown_function(
378+
function () use ( $old_temp ) {
379+
if ( file_exists( $old_temp ) ) {
380+
unlink( $old_temp );
380381
}
381-
);
382-
}
382+
}
383+
);
383384
}
384385
} else {
385386
$temp = $actual_temp;

0 commit comments

Comments
 (0)