From 3c0c81bb94456479b36e968eb77fe3e23ce2dcc1 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 18 Sep 2024 13:54:21 +0200 Subject: fix: ensure parent folder exists when writing a file to object storage Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/private/Files/ObjectStore') diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 631ebf5bc81..60affa4b89e 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -492,6 +492,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); } -- cgit v1.2.3