Skip to content

Commit 7f5a780

Browse files
author
matt
committed
Only overwrite files, not directories
1 parent 0993e28 commit 7f5a780

File tree

2 files changed

+0
-42
lines changed

2 files changed

+0
-42
lines changed

src/PhpseclibV3/SftpAdapter.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,6 @@ public function move(string $source, string $destination, Config $config): void
328328
if ($connection->rename($sourceLocation, $destinationLocation)) {
329329
return;
330330
}
331-
} elseif ($connection->is_dir($destinationLocation)) {
332-
$this->deleteDirectory($destination);
333-
if ($connection->rename($sourceLocation, $destinationLocation)) {
334-
return;
335-
}
336331
}
337332

338333
throw UnableToMoveFile::fromLocationTo($source, $destination);

src/PhpseclibV3/SftpAdapterTest.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -247,43 +247,6 @@ public function moving_a_file_and_overwriting(): void
247247
});
248248
}
249249

250-
/**
251-
* @test
252-
* @fixme Move to FilesystemAdapterTestCase once all adapters pass
253-
*/
254-
public function moving_a_directory_and_overwriting(): void
255-
{
256-
$this->runScenario(function() {
257-
$adapter = $this->adapter();
258-
$config = new Config();
259-
260-
$adapter->createDirectory('move_and_overwrite_source', $config);
261-
$adapter->write('move_and_overwrite_source/a', 'a', $config);
262-
263-
$adapter->createDirectory('move_and_overwrite_target', $config);
264-
$adapter->write('move_and_overwrite_target/b', 'b', $config);
265-
266-
$adapter->move('move_and_overwrite_source', 'move_and_overwrite_target', $config);
267-
268-
$this->assertFalse(
269-
$adapter->directoryExists('move_and_overwrite_source'),
270-
'Source directory should not exist'
271-
);
272-
$this->assertTrue(
273-
$adapter->directoryExists('move_and_overwrite_target'),
274-
'Target directory should exist'
275-
);
276-
$this->assertTrue(
277-
$adapter->fileExists('move_and_overwrite_target/a'),
278-
'Source files not moved'
279-
);
280-
$this->assertFalse(
281-
$adapter->fileExists('move_and_overwrite_target/b'),
282-
'Target files not deleted'
283-
);
284-
});
285-
}
286-
287250
private static function connectionProvider(): ConnectionProvider
288251
{
289252
if ( ! static::$connectionProvider instanceof ConnectionProvider) {

0 commit comments

Comments
 (0)