]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix renameFromStorage messing with folder mimetype
authorRobin Appelman <robin@icewind.nl>
Thu, 23 Jul 2020 18:31:35 +0000 (20:31 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 31 Jul 2020 15:33:17 +0000 (17:33 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Cache/Updater.php

index 59cff9b3a41106bb002f86a538c3cd4ddd103c42..7c222b310326b8cdfee55ca3a1d2ab34a7cba6ef 100644 (file)
@@ -27,6 +27,7 @@
 
 namespace OC\Files\Cache;
 
+use OC\Files\FileInfo;
 use OCP\Files\Cache\ICacheEntry;
 use OCP\Files\Cache\IUpdater;
 use OCP\Files\Storage\IStorage;
@@ -187,7 +188,9 @@ class Updater implements IUpdater {
                $sourceUpdater = $sourceStorage->getUpdater();
                $sourcePropagator = $sourceStorage->getPropagator();
 
-               if ($sourceCache->inCache($source)) {
+               $sourceInfo = $sourceCache->get($source);
+
+               if ($sourceInfo !== false) {
                        if ($this->cache->inCache($target)) {
                                $this->cache->remove($target);
                        }
@@ -197,13 +200,13 @@ class Updater implements IUpdater {
                        } else {
                                $this->cache->moveFromCache($sourceCache, $source, $target);
                        }
-               }
 
-               if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION)) {
-                       // handle mime type change
-                       $mimeType = $this->storage->getMimeType($target);
-                       $fileId = $this->cache->getId($target);
-                       $this->cache->update($fileId, ['mimetype' => $mimeType]);
+                       if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION) && $sourceInfo->getMimeType() !== FileInfo::MIMETYPE_FOLDER) {
+                               // handle mime type change
+                               $mimeType = $this->storage->getMimeType($target);
+                               $fileId = $this->cache->getId($target);
+                               $this->cache->update($fileId, ['mimetype' => $mimeType]);
+                       }
                }
 
                if ($sourceCache instanceof Cache) {