Skip to content
Merged
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
Next Next commit
use mimetype from cache for workflow if available
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and backportbot-nextcloud[bot] committed Dec 20, 2022
commit 783dae94cf9d0b7bf2165a59e48ecb57345aeebf
12 changes: 8 additions & 4 deletions apps/workflowengine/lib/Check/FileMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
namespace OCA\WorkflowEngine\Check;

use OC\Files\Storage\Local;
use OCA\WorkflowEngine\Entity\File;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\Storage\IStorage;
Expand Down Expand Up @@ -122,12 +123,15 @@ protected function getActualValue() {
if ($this->mimeType[$this->storage->getId()][$this->path] !== null) {
return $this->mimeType[$this->storage->getId()][$this->path];
}

if ($this->storage->is_dir($this->path)) {
return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, 'httpd/unix-directory');
$cacheEntry = $this->storage->getCache()->get($this->path);
if ($cacheEntry && $cacheEntry->getMimeType() !== 'application/octet-stream') {
return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $cacheEntry->getMimeType());
}

if ($this->storage->file_exists($this->path) && $this->storage->filesize($this->path)) {
if ($this->storage->file_exists($this->path) &&
$this->storage->filesize($this->path) &&
$this->storage->instanceOfStorage(Local::class)
) {
$path = $this->storage->getLocalFile($this->path);
$mimeType = $this->mimeTypeDetector->detectContent($path);
return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType);
Expand Down