Skip to content

Commit 30cc7fc

Browse files
authored
Merge pull request #71 from tinect/feat/movingFileToSameDest
2 parents d32e5c5 + 4835a40 commit 30cc7fc

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/BunnyCDNAdapter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ public function fileSize(string $path): FileAttributes
399399
*/
400400
public function move(string $source, string $destination, Config $config): void
401401
{
402+
if ($source === $destination) {
403+
return;
404+
}
405+
402406
try {
403407
/** @var array<string> $files */
404408
$files = iterator_to_array($this->getFiles($source));

tests/FlysystemAdapterTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,26 @@ public function overwriting_a_file(): void
261261
});
262262
}
263263

264+
/**
265+
* @test
266+
*/
267+
public function moving_a_file_to_same_destination(): void
268+
{
269+
$this->runScenario(function () {
270+
$adapter = $this->adapter();
271+
$adapter->write(
272+
'source.txt',
273+
'contents to be copied',
274+
new Config([Config::OPTION_VISIBILITY => Visibility::PUBLIC])
275+
);
276+
$adapter->move('source.txt', 'source.txt', new Config());
277+
$this->assertTrue(
278+
$adapter->fileExists('source.txt'),
279+
'After moving a file to the same location the file should exist.'
280+
);
281+
});
282+
}
283+
264284
/**
265285
* @test
266286
*/

0 commit comments

Comments
 (0)