From 22af5a392e46bdf7e48fc74f711a02a1e09ee9cf Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Sat, 17 Aug 2024 15:10:48 +0200 Subject: [PATCH] Make same path copy/move a no-op for AWS S3 --- src/AsyncAwsS3/AsyncAwsS3Adapter.php | 9 ++++++++- src/AwsS3V3/AwsS3V3Adapter.php | 8 ++++++++ src/AwsS3V3/AwsS3V3AdapterTest.php | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/AsyncAwsS3/AsyncAwsS3Adapter.php b/src/AsyncAwsS3/AsyncAwsS3Adapter.php index b8248fb06..ab52be10d 100644 --- a/src/AsyncAwsS3/AsyncAwsS3Adapter.php +++ b/src/AsyncAwsS3/AsyncAwsS3Adapter.php @@ -307,6 +307,10 @@ public function listContents(string $path, bool $deep): iterable public function move(string $source, string $destination, Config $config): void { + if ($source === $destination) { + return; + } + try { $this->copy($source, $destination, $config); $this->delete($source); @@ -317,8 +321,11 @@ public function move(string $source, string $destination, Config $config): void public function copy(string $source, string $destination, Config $config): void { - try { + if ($source === $destination) { + return; + } + try { $visibility = $config->get(Config::OPTION_VISIBILITY); if ($visibility === null && $config->get(Config::OPTION_RETAIN_VISIBILITY, true)) { diff --git a/src/AwsS3V3/AwsS3V3Adapter.php b/src/AwsS3V3/AwsS3V3Adapter.php index 40174e1d6..c0203352d 100644 --- a/src/AwsS3V3/AwsS3V3Adapter.php +++ b/src/AwsS3V3/AwsS3V3Adapter.php @@ -407,6 +407,10 @@ private function retrievePaginatedListing(array $options): Generator public function move(string $source, string $destination, Config $config): void { + if ($source === $destination) { + return; + } + try { $this->copy($source, $destination, $config); $this->delete($source); @@ -417,6 +421,10 @@ public function move(string $source, string $destination, Config $config): void public function copy(string $source, string $destination, Config $config): void { + if ($source === $destination) { + return; + } + try { $visibility = $config->get(Config::OPTION_VISIBILITY); diff --git a/src/AwsS3V3/AwsS3V3AdapterTest.php b/src/AwsS3V3/AwsS3V3AdapterTest.php index 04daa6683..d2fbb5c66 100644 --- a/src/AwsS3V3/AwsS3V3AdapterTest.php +++ b/src/AwsS3V3/AwsS3V3AdapterTest.php @@ -81,7 +81,7 @@ protected function tearDown(): void protected function setUp(): void { - if (PHP_VERSION_ID < 801000) { + if (PHP_VERSION_ID < 80100) { $this->markTestSkipped('AWS does not support this anymore.'); }