aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-09-13 16:36:25 +0200
committerRobin Appelman <robin@icewind.nl>2024-12-05 18:05:13 +0100
commit37199779de89674790b36eb6b0a863b2e6eb567b (patch)
tree255a3c821c20c892698bbe0a7b9be03bc480e4cf /lib
parent7bc21d8a34e9d4a0a066a0069a9a7abf13158368 (diff)
downloadnextcloud-server-37199779de89674790b36eb6b0a863b2e6eb567b.tar.gz
nextcloud-server-37199779de89674790b36eb6b0a863b2e6eb567b.zip
fix: fix mimetype not being updated when changing file extention on object storeupdater-change-mimetype-objectstore
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/Updater.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php
index aa025a3a96c..62e2aa4f752 100644
--- a/lib/private/Files/Cache/Updater.php
+++ b/lib/private/Files/Cache/Updater.php
@@ -205,21 +205,25 @@ class Updater implements IUpdater {
$sourceInfo = $sourceCache->get($source);
+ $sourceExtension = pathinfo($source, PATHINFO_EXTENSION);
+ $targetExtension = pathinfo($target, PATHINFO_EXTENSION);
+ $targetIsTrash = preg_match("/^d\d+$/", $targetExtension);
+
if ($sourceInfo !== false) {
if (!$this->storage->instanceOfStorage(ObjectStoreStorage::class)) {
$operation($sourceCache, $sourceInfo);
}
- $sourceExtension = pathinfo($source, PATHINFO_EXTENSION);
- $targetExtension = pathinfo($target, PATHINFO_EXTENSION);
- $targetIsTrash = preg_match("/d\d+/", $targetExtension);
+ $isDir = $sourceInfo->getMimeType() === FileInfo::MIMETYPE_FOLDER;
+ } else {
+ $isDir = $this->storage->is_dir($target);
+ }
- if ($sourceExtension !== $targetExtension && $sourceInfo->getMimeType() !== FileInfo::MIMETYPE_FOLDER && !$targetIsTrash) {
- // handle mime type change
- $mimeType = $this->storage->getMimeType($target);
- $fileId = $this->cache->getId($target);
- $this->cache->update($fileId, ['mimetype' => $mimeType]);
- }
+ if ($sourceExtension !== $targetExtension && !$isDir && !$targetIsTrash) {
+ // handle mime type change
+ $mimeType = $this->storage->getMimeType($target);
+ $fileId = $this->cache->getId($target);
+ $this->cache->update($fileId, ['mimetype' => $mimeType]);
}
if ($sourceCache instanceof Cache) {