Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow to specify apps that somethign is a dir
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Dec 10, 2019
commit 4a151c545a6f255f8d8e293cbd673fadc518391e
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;

}