Browse Source
Allow to specify apps that somethign is a dir
Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/18236/head
Joas Schilling
7 years ago
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
4 changed files with
22 additions and
7 deletions
-
apps/workflowengine/lib/Check/FileMimeType.php
-
apps/workflowengine/lib/Check/TFileCheck.php
-
apps/workflowengine/lib/Service/RuleMatcher.php
-
lib/public/WorkflowEngine/IFileCheck.php
|
|
|
@ -57,12 +57,18 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck { |
|
|
|
/** |
|
|
|
* @param IStorage $storage |
|
|
|
* @param string $path |
|
|
|
* @param bool $isDir |
|
|
|
*/ |
|
|
|
public function setFileInfo(IStorage $storage, string $path) { |
|
|
|
$this->_setFileInfo($storage, $path); |
|
|
|
public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
|
|
$this->_setFileInfo($storage, $path, $isDir); |
|
|
|
if (!isset($this->mimeType[$this->storage->getId()][$this->path]) |
|
|
|
|| $this->mimeType[$this->storage->getId()][$this->path] === '') { |
|
|
|
$this->mimeType[$this->storage->getId()][$this->path] = null; |
|
|
|
|
|
|
|
if ($isDir) { |
|
|
|
$this->mimeType[$this->storage->getId()][$this->path] = 'httpd/unix-directory'; |
|
|
|
} else { |
|
|
|
$this->mimeType[$this->storage->getId()][$this->path] = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -37,14 +37,19 @@ trait TFileCheck { |
|
|
|
/** @var string */ |
|
|
|
protected $path; |
|
|
|
|
|
|
|
/** @var bool */ |
|
|
|
protected $isDir; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param IStorage $storage |
|
|
|
* @param string $path |
|
|
|
* @param bool $isDir |
|
|
|
* @since 18.0.0 |
|
|
|
*/ |
|
|
|
public function setFileInfo(IStorage $storage, string $path) { |
|
|
|
public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
|
|
$this->storage = $storage; |
|
|
|
$this->path = $path; |
|
|
|
$this->isDir = $isDir; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
@ -71,9 +71,10 @@ class RuleMatcher implements IRuleMatcher { |
|
|
|
$this->l = $l; |
|
|
|
} |
|
|
|
|
|
|
|
public function setFileInfo(IStorage $storage, string $path): void { |
|
|
|
public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
|
|
$this->fileInfo['storage'] = $storage; |
|
|
|
$this->fileInfo['path'] = $path; |
|
|
|
$this->fileInfo['isDir'] = $isDir; |
|
|
|
} |
|
|
|
|
|
|
|
public function setEntitySubject(IEntity $entity, $subject): void { |
|
|
|
@ -168,7 +169,7 @@ class RuleMatcher implements IRuleMatcher { |
|
|
|
if (empty($this->fileInfo)) { |
|
|
|
throw new RuntimeException('Must set file info before running the check'); |
|
|
|
} |
|
|
|
$checkInstance->setFileInfo($this->fileInfo['storage'], $this->fileInfo['path']); |
|
|
|
$checkInstance->setFileInfo($this->fileInfo['storage'], $this->fileInfo['path'], $this->fileInfo['isDir']); |
|
|
|
} elseif ($checkInstance instanceof IEntityCheck) { |
|
|
|
foreach($this->contexts as $entityInfo) { |
|
|
|
list($entity, $subject) = $entityInfo; |
|
|
|
|
|
|
|
@ -37,8 +37,11 @@ use OCP\Files\Storage\IStorage; |
|
|
|
*/ |
|
|
|
interface IFileCheck extends IEntityCheck { |
|
|
|
/** |
|
|
|
* @param IStorage $storage |
|
|
|
* @param string $path |
|
|
|
* @param bool $isDir |
|
|
|
* @since 18.0.0 |
|
|
|
*/ |
|
|
|
public function setFileInfo(IStorage $storage, string $path); |
|
|
|
public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void; |
|
|
|
|
|
|
|
} |