From 78dcf3744da1b5f8a120939616ead080bd33bb20 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 5 Aug 2025 11:18:50 +0200 Subject: [PATCH] Revert "feat: Implement Directory Check" This reverts commit feae8ba16a9c213016c41be0a7b8571a3a1a907e. --- .../composer/composer/autoload_classmap.php | 1 - .../composer/composer/autoload_static.php | 1 - apps/workflowengine/lib/Check/Directory.php | 58 ---------------- apps/workflowengine/lib/Manager.php | 2 - .../src/components/Checks/file.js | 13 ---- .../tests/Check/DirectoryTest.php | 68 ------------------- build/psalm-baseline.xml | 1 - 7 files changed, 144 deletions(-) delete mode 100644 apps/workflowengine/lib/Check/Directory.php delete mode 100644 apps/workflowengine/tests/Check/DirectoryTest.php diff --git a/apps/workflowengine/composer/composer/autoload_classmap.php b/apps/workflowengine/composer/composer/autoload_classmap.php index 52d221fb767..0444cce13e7 100644 --- a/apps/workflowengine/composer/composer/autoload_classmap.php +++ b/apps/workflowengine/composer/composer/autoload_classmap.php @@ -10,7 +10,6 @@ return array( 'OCA\\WorkflowEngine\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\WorkflowEngine\\BackgroundJobs\\Rotate' => $baseDir . '/../lib/BackgroundJobs/Rotate.php', 'OCA\\WorkflowEngine\\Check\\AbstractStringCheck' => $baseDir . '/../lib/Check/AbstractStringCheck.php', - 'OCA\\WorkflowEngine\\Check\\Directory' => $baseDir . '/../lib/Check/Directory.php', 'OCA\\WorkflowEngine\\Check\\FileMimeType' => $baseDir . '/../lib/Check/FileMimeType.php', 'OCA\\WorkflowEngine\\Check\\FileName' => $baseDir . '/../lib/Check/FileName.php', 'OCA\\WorkflowEngine\\Check\\FileSize' => $baseDir . '/../lib/Check/FileSize.php', diff --git a/apps/workflowengine/composer/composer/autoload_static.php b/apps/workflowengine/composer/composer/autoload_static.php index 57b569dbc10..0b9ac89ae30 100644 --- a/apps/workflowengine/composer/composer/autoload_static.php +++ b/apps/workflowengine/composer/composer/autoload_static.php @@ -25,7 +25,6 @@ class ComposerStaticInitWorkflowEngine 'OCA\\WorkflowEngine\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\WorkflowEngine\\BackgroundJobs\\Rotate' => __DIR__ . '/..' . '/../lib/BackgroundJobs/Rotate.php', 'OCA\\WorkflowEngine\\Check\\AbstractStringCheck' => __DIR__ . '/..' . '/../lib/Check/AbstractStringCheck.php', - 'OCA\\WorkflowEngine\\Check\\Directory' => __DIR__ . '/..' . '/../lib/Check/Directory.php', 'OCA\\WorkflowEngine\\Check\\FileMimeType' => __DIR__ . '/..' . '/../lib/Check/FileMimeType.php', 'OCA\\WorkflowEngine\\Check\\FileName' => __DIR__ . '/..' . '/../lib/Check/FileName.php', 'OCA\\WorkflowEngine\\Check\\FileSize' => __DIR__ . '/..' . '/../lib/Check/FileSize.php', diff --git a/apps/workflowengine/lib/Check/Directory.php b/apps/workflowengine/lib/Check/Directory.php deleted file mode 100644 index f7b856a95fe..00000000000 --- a/apps/workflowengine/lib/Check/Directory.php +++ /dev/null @@ -1,58 +0,0 @@ -path === null) { - return ''; - } - // files/some/path -> some/path - return preg_replace('/^files\//', '', pathinfo($this->path, PATHINFO_DIRNAME)); - } - - /** - * @param string $operator - * @param string $checkValue - * @param string $actualValue - * @return bool - */ - protected function executeStringCheck($operator, $checkValue, $actualValue) { - if ($operator === 'is' || $operator === '!is') { - $checkValue = ltrim(rtrim($checkValue, '/'), '/'); - } - return parent::executeStringCheck($operator, $checkValue, $actualValue); - } - - public function supportedEntities(): array { - return [ File::class ]; - } - - public function isAvailableForScope(int $scope): bool { - return true; - } -} diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index 27b25a2e752..0f41679789d 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -8,7 +8,6 @@ namespace OCA\WorkflowEngine; use Doctrine\DBAL\Exception; use OCA\WorkflowEngine\AppInfo\Application; -use OCA\WorkflowEngine\Check\Directory; use OCA\WorkflowEngine\Check\FileMimeType; use OCA\WorkflowEngine\Check\FileName; use OCA\WorkflowEngine\Check\FileSize; @@ -693,7 +692,6 @@ class Manager implements IManager { protected function getBuildInChecks(): array { try { return [ - $this->container->query(Directory::class), $this->container->query(FileMimeType::class), $this->container->query(FileName::class), $this->container->query(FileSize::class), diff --git a/apps/workflowengine/src/components/Checks/file.js b/apps/workflowengine/src/components/Checks/file.js index b2d348e4712..568efc81cd3 100644 --- a/apps/workflowengine/src/components/Checks/file.js +++ b/apps/workflowengine/src/components/Checks/file.js @@ -31,19 +31,6 @@ const FileChecks = [ validate: stringValidator, }, - { - class: 'OCA\\WorkflowEngine\\Check\\Directory', - name: t('workflowengine', 'Directory'), - operators: stringOrRegexOperators, - placeholder: (check) => { - if (check.operator === 'matches' || check.operator === '!matches') { - return '/^myfolder/.+$/i' - } - return 'myfolder/subfolder' - }, - validate: stringValidator, - }, - { class: 'OCA\\WorkflowEngine\\Check\\FileMimeType', name: t('workflowengine', 'File MIME type'), diff --git a/apps/workflowengine/tests/Check/DirectoryTest.php b/apps/workflowengine/tests/Check/DirectoryTest.php deleted file mode 100644 index 6eef082b5e5..00000000000 --- a/apps/workflowengine/tests/Check/DirectoryTest.php +++ /dev/null @@ -1,68 +0,0 @@ -l10n = $this->createMock(IL10N::class); - $this->storage = $this->createMock(IStorage::class); - $this->directory = new Directory($this->l10n); - } - - /** - * @dataProvider dataProviderCheck - */ - public function testExecuteStringCheck(string $operator, string $configuredDirectoryPath, string $filePath, bool $expectedResult): void { - $this->directory->setFileInfo($this->storage, $filePath); - - $result = $this->directory->executeCheck($operator, $configuredDirectoryPath); - - $this->assertEquals($expectedResult, $result); - } - - public function testSupportedEntities(): void { - $this->assertSame([File::class], $this->directory->supportedEntities()); - } - - public function testIsAvailableForScope(): void { - $this->assertTrue($this->directory->isAvailableForScope(1)); - } - - public function dataProviderCheck(): array { - return [ - ['is', 'some/path', 'files/some/path/file.txt', true], - ['is', '/some/path/', 'files/some/path/file.txt', true], - - ['!is', 'some/path', 'files/some/path/file.txt', false], - ['!is', 'some/path/', 'files/someother/path/file.txt', true], - - ['matches', '/^some\/path\/.+$/i', 'files/SomE/PATH/subfolder/file.txt', true], - ['matches', '/some\/path\/.*\/sub2/', 'files/some/path/subfolder1/sub2/anotherfile.pdf', true], - - ['!matches', '/some\/path/', 'files/some/path/file.txt', false], - ['!matches', '/some\/path/', 'files/another/path/file.txt', true], - ]; - } -} diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 73dfeab49e4..596ff92519e 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -2783,7 +2783,6 @@ -