mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
fix: Avoid failing with duplicate checks
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
e9df5b22c4
commit
13d5407085
2 changed files with 4 additions and 10 deletions
|
|
@ -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…
Reference in a new issue