Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions apps/files_external/tests/Storage/Amazons3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->assertNotFalse(
$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'));
}
}
Loading