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 @@ - - - - -