aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-02-23 17:32:23 +0100
committerVincent Petry <vincent@nextcloud.com>2022-12-20 13:28:33 +0100
commitc5a82467429e5e09b740009d19758a3df38a7f4d (patch)
treef62c7792a7b9bb82686b1a876f689d1abf03b279 /apps
parent4d0403009d8449a88faf7ffc3c6df196c5ac9948 (diff)
downloadnextcloud-server-c5a82467429e5e09b740009d19758a3df38a7f4d.tar.gz
nextcloud-server-c5a82467429e5e09b740009d19758a3df38a7f4d.zip
use mimetype from cache for workflow if available
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/workflowengine/lib/Check/FileMimeType.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php
index 42b93bd9513..8213010af05 100644
--- a/apps/workflowengine/lib/Check/FileMimeType.php
+++ b/apps/workflowengine/lib/Check/FileMimeType.php
@@ -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;
@@ -122,12 +123,15 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
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);