Skip to content

Commit

Permalink
Allow to specify apps that somethign is a dir
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Dec 10, 2019
1 parent 511a4ba commit 4a151c5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
12 changes: 9 additions & 3 deletions apps/workflowengine/lib/Check/FileMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mime
/**
* @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;
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion apps/workflowengine/lib/Check/TFileCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions apps/workflowengine/lib/Service/RuleMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ public function __construct(
$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 {
Expand Down Expand Up @@ -168,7 +169,7 @@ public function check(array $check) {
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;
Expand Down
5 changes: 4 additions & 1 deletion lib/public/WorkflowEngine/IFileCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
*/
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;

}

0 comments on commit 4a151c5

Please sign in to comment.