]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: ensure parent folder exists when writing a file to object storage
authorRobin Appelman <robin@icewind.nl>
Wed, 18 Sep 2024 11:54:21 +0000 (13:54 +0200)
committerLouis <louis@chmn.me>
Tue, 8 Oct 2024 16:14:26 +0000 (18:14 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/ObjectStore/ObjectStoreStorage.php

index 056776326076090dc00f6e6aee8e984d24c4891d..c9fbe11bbfa475cf8633f0096a0fca7394eaa04a 100644 (file)
@@ -514,6 +514,10 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
                if ($exists) {
                        $fileId = $stat['fileid'];
                } else {
+                       $parent = $this->normalizePath(dirname($path));
+                       if (!$this->is_dir($parent)) {
+                               throw new \InvalidArgumentException("trying to upload a file ($path) inside a non-directory ($parent)");
+                       }
                        $fileId = $this->getCache()->put($uploadPath, $stat);
                }