diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-12-12 13:19:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-12 13:19:59 +0100 |
commit | d108a12b0e782834fed6c42d5e95469a010c7a36 (patch) | |
tree | 6938d0876c5bca237da8ce0e33ebe9dd39ce22ec /lib | |
parent | 256e9a94045025707eaae3e416d167fcbe3ee459 (diff) | |
parent | c3a2d789f1824e3a86826e46dc2e66e6894849e8 (diff) | |
download | nextcloud-server-d108a12b0e782834fed6c42d5e95469a010c7a36.tar.gz nextcloud-server-d108a12b0e782834fed6c42d5e95469a010c7a36.zip |
Merge pull request #49794 from nextcloud/backport/40394/stable30
[stable30] fix mimetype not being updated when changing file extention on objectstore
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Cache/Updater.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php index e8c6d32599e..953b7ba9607 100644 --- a/lib/private/Files/Cache/Updater.php +++ b/lib/private/Files/Cache/Updater.php @@ -176,6 +176,10 @@ 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->cache->inCache($target)) { $this->cache->remove($target); @@ -187,16 +191,16 @@ class Updater implements IUpdater { $this->cache->moveFromCache($sourceCache, $source, $target); } - $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) { |