Skip to content

Commit

Permalink
Revert "fix(files): better handle directories in move() (#4970)" (#5011)
Browse files Browse the repository at this point in the history
This reverts commit 39d4802.
  • Loading branch information
rebeccahum committed Nov 7, 2023
1 parent 51c6e81 commit f9260a7
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions files/class-wp-filesystem-vip.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ public function copy( $source, $destination, $overwrite = false, $mode = false )
return false;
}

if ( $source_transport instanceof WP_Filesystem_Direct && $destination_transport instanceof WP_Filesystem_Direct ) {
return $source_transport->copy( $source, $destination, $overwrite, $mode );
}

$destination_exists = $destination_transport->exists( $destination );
if ( ! $overwrite && $destination_exists ) {
/* translators: 1: destination file path 2: overwrite param 3: `true` boolean value */
Expand Down Expand Up @@ -252,24 +248,13 @@ public function copy( $source, $destination, $overwrite = false, $mode = false )
* @return bool
*/
public function move( $source, $destination, $overwrite = false ) {
$source_transport = $this->get_transport_for_path( $source );
$destination_transport = $this->get_transport_for_path( $destination, 'write' );
if ( $source_transport instanceof WP_Filesystem_Direct && $destination_transport instanceof WP_Filesystem_Direct ) {
return $source_transport->move( $source, $destination, $overwrite );
}

// WP_Filesystem_Direct::get_contents() invoked by copy() will return '' for directories; this will result in directories being copied as empty files.
if ( $source_transport->is_file( $source ) ) {
$copy_results = $this->copy( $source, $destination, $overwrite );
if ( false === $copy_results ) {
return false;
}

// We don't need to set the errors here since delete() will take care of it
return $this->delete( $source );
$copy_results = $this->copy( $source, $destination, $overwrite );
if ( false === $copy_results ) {
return false;
}

return false;
// We don't need to set the errors here since delete() will take care of it
return $this->delete( $source );
}

/**
Expand Down

0 comments on commit f9260a7

Please sign in to comment.