From 77e0403cccd7345ddce7902f21cc9f01af836d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 23 Feb 2023 13:04:32 +0100 Subject: [PATCH] fix: Avoid failing with duplicate checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/workflowengine/lib/Check/FileMimeType.php | 8 +------- apps/workflowengine/tests/Check/FileMimeTypeTest.php | 6 +++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php index 991d7ebc739ed..dfcfed9466bb0 100644 --- a/apps/workflowengine/lib/Check/FileMimeType.php +++ b/apps/workflowengine/lib/Check/FileMimeType.php @@ -107,13 +107,7 @@ protected function cacheAndReturnMimeType(string $storageId, ?string $path, stri * @return bool */ public function executeCheck($operator, $value) { - $actualValue = $this->getActualValue(); - $plainMimetypeResult = $this->executeStringCheck($operator, $value, $actualValue); - if ($actualValue === 'httpd/unix-directory') { - return $plainMimetypeResult; - } - $detectMimetypeBasedOnFilenameResult = $this->executeStringCheck($operator, $value, $this->mimeTypeDetector->detectPath($this->path)); - return $plainMimetypeResult || $detectMimetypeBasedOnFilenameResult; + return $this->executeStringCheck($operator, $value, $this->getActualValue()); } /** diff --git a/apps/workflowengine/tests/Check/FileMimeTypeTest.php b/apps/workflowengine/tests/Check/FileMimeTypeTest.php index 3ebcaa8f4b3a9..e5a4c99269f42 100644 --- a/apps/workflowengine/tests/Check/FileMimeTypeTest.php +++ b/apps/workflowengine/tests/Check/FileMimeTypeTest.php @@ -127,7 +127,7 @@ public function testNonCachedNotLocal() { $check = new FileMimeType($this->l10n, $this->request, $this->mimeDetector); $check->setFileInfo($storage, 'foo/bar.txt'); - $this->assertTrue($check->executeCheck('is', 'text/plain-path-detected')); + $this->assertTrue($check->executeCheck('is', 'text/plain-content-detected')); } public function testFallback() { @@ -142,7 +142,7 @@ public function testFallback() { public function testFromCacheCached() { $storage = new Temporary([]); $storage->mkdir('foo'); - $storage->file_put_contents('foo/bar.txt', 'asd'); + $storage->file_put_contents('foo/bar.txt', 'text-content'); $storage->getScanner()->scan(''); $check = new FileMimeType($this->l10n, $this->request, $this->mimeDetector); @@ -156,7 +156,7 @@ public function testFromCacheCached() { $newCheck = new FileMimeType($this->l10n, $this->request, $this->mimeDetector); $newCheck->setFileInfo($storage, 'foo/bar.txt'); - $this->assertTrue($newCheck->executeCheck('is', 'text/plain-path-detected')); + $this->assertTrue($newCheck->executeCheck('is', 'text/plain-content-detected')); } public function testExistsCached() {