From c101483867c6e21cabffbab8c02f5b14b7058fb2 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 25 Feb 2026 12:10:18 -0500 Subject: [PATCH 1/2] test(AmazonS3): add batchDelete test (>1000) Signed-off-by: Josh --- .../tests/Storage/Amazons3Test.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php index 90e36d5fdbd74..407f74994d117 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -41,4 +41,42 @@ protected function tearDown(): void { public function testStat(): void { $this->markTestSkipped('S3 doesn\'t update the parents folder mtime'); } + + /** + * Test rmdir() with a directory containing more than 1000 files to validate S3 batchDelete logic. + */ + public function testRmdirManyFiles() { + $dir = 'bigDir'; + $numFiles = 1100; // S3 batchDelete limit is 1000 + + // Create the directory + $this->assertTrue($this->instance->mkdir($dir)); + + // Create 1100 files inside the directory + for ($i = 0; $i < $numFiles; $i++) { + $filePath = $dir . '/file' . $i . '.txt'; + $this->assertTrue( + $this->instance->file_put_contents($filePath, 'test content'), + "Failed to create file: $filePath" + ); + } + + $this->wait(); + // Confirm directory and files exist + $this->assertTrue($this->instance->is_dir($dir)); + $this->assertTrue($this->instance->file_exists($dir . '/file0.txt')); + $this->assertTrue($this->instance->file_exists($dir . '/file1099.txt')); + + // Delete the directory (should trigger multi-batchDelete in S3) + $this->assertTrue( + $this->instance->rmdir($dir), + 'rmdir failed on bigDir with many files' + ); + + $this->wait(); + // Confirm directory and files are deleted + $this->assertFalse($this->instance->file_exists($dir)); + $this->assertFalse($this->instance->file_exists($dir . '/file0.txt')); + $this->assertFalse($this->instance->file_exists($dir . '/file1099.txt')); + } } From 483980f647cbfd03f9e25620147367b485453f07 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 25 Feb 2026 12:38:53 -0500 Subject: [PATCH 2/2] chore: fixup Amazons3Test.php Signed-off-by: Josh --- apps/files_external/tests/Storage/Amazons3Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php index 407f74994d117..41f3e0655adbe 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -55,7 +55,7 @@ public function testRmdirManyFiles() { // Create 1100 files inside the directory for ($i = 0; $i < $numFiles; $i++) { $filePath = $dir . '/file' . $i . '.txt'; - $this->assertTrue( + $this->assertNotFalse( $this->instance->file_put_contents($filePath, 'test content'), "Failed to create file: $filePath" );