fix: Avoid failing with duplicate checks

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/36830/head
Julius Härtl 2 years ago
parent 706c141fff
commit 06d80ba809
  1. 8
      apps/workflowengine/lib/Check/FileMimeType.php
  2. 6
      apps/workflowengine/tests/Check/FileMimeTypeTest.php

@ -107,13 +107,7 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
* @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());
}
/**

@ -127,7 +127,7 @@ class FileMimeTypeTest extends TestCase {
$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 @@ class FileMimeTypeTest extends TestCase {
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 @@ class FileMimeTypeTest extends TestCase {
$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() {

Loading…
Cancel
Save