From: Robin Appelman Date: Wed, 18 Sep 2024 11:54:21 +0000 (+0200) Subject: fix: ensure parent folder exists when writing a file to object storage X-Git-Tag: v28.0.11~2^2~15 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6421581c0084a5a093cfd91f9c93b8d46112746a;p=nextcloud-server.git fix: ensure parent folder exists when writing a file to object storage Signed-off-by: Robin Appelman --- diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 05677632607..c9fbe11bbfa 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -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); }