Skip to content

Commit

Permalink
fix: Avoid failing with duplicate checks
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Sep 12, 2023
1 parent 82ec950 commit 0c8b36a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 1 addition & 7 deletions apps/workflowengine/lib/Check/FileMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions apps/workflowengine/tests/Check/FileMimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
Expand All @@ -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() {
Expand Down

0 comments on commit 0c8b36a

Please sign in to comment.