Backend: an existing folder that cannot be listed is an error, not empty

Read as empty, a catalog/ or index/ folder would make an existing repository look new.
This commit is contained in:
2026-10-08 20:46:14 +02:00
parent ab3265e42c
commit fe1a289c2d
3 changed files with 16 additions and 2 deletions
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace OCA\NgBackup\Tests\Unit\Backend;
use OCA\NgBackup\Backend\BackendException;
use OCA\NgBackup\Backend\StorageBackend;
use OCA\NgBackup\Tests\Unit\TempDirTrait;
use OCP\Files\Storage\IStorage;
@@ -44,4 +45,13 @@ class StorageBackendListTest extends TestCase {
$storage->expects($this->never())->method('opendir');
$this->assertSame([], (new StorageBackend($storage, 'repo'))->listFiles('snapshots'));
}
public function testAnUnreadableFolderIsAnErrorNotEmpty(): void {
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')->willReturn(false);
$storage->method('is_dir')->willReturn(true);
$storage->method('opendir')->willReturn(false);
$this->expectException(BackendException::class);
(new StorageBackend($storage, 'repo'))->listFiles('catalog');
}
}