mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
use mimetype from cache for workflow if available
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
4d0403009d
commit
c5a8246742
1 changed files with 8 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue