From cd6535bc593583ff462379ab3083d3923ea14925 Mon Sep 17 00:00:00 2001 From: grnd-alt Date: Thu, 4 Apr 2024 16:26:16 +0200 Subject: [PATCH] get freespace from file parent Signed-off-by: grnd-alt --- lib/Controller/WopiController.php | 14 +++++++------- psalm.xml | 5 ----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index bfca2f5cd8..9139240227 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -485,20 +485,20 @@ public function putFile($fileId, $content = fopen('php://input', 'rb'); + $freespace = $file->getParent()->getFreeSpace(); + // Get expected FileSize after writing - $storage = \OC_Helper::getStorageInfo($path); fseek($content, 0, SEEK_END); - $finalSize = ftell($content) + $file->getSize(); + $finalSize = ftell($content); rewind($content); try { - if ($finalSize <= $storage['free']) { - $this->wrappedFilesystemOperation($wopi, function () use ($file, $content) { - return $file->putContent($content); - }); - } else { + if ($finalSize > $freespace) { throw new \Exception('Not enough storage'); } + $this->wrappedFilesystemOperation($wopi, function () use ($file, $content) { + return $file->putContent($content); + }); } catch (LockedException $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR); diff --git a/psalm.xml b/psalm.xml index e9158fd2e7..df3d8e5d85 100644 --- a/psalm.xml +++ b/psalm.xml @@ -23,11 +23,6 @@ - - - - -