Skip to content

Commit

Permalink
Merge pull request #3562 from nextcloud/fix/3281-file-gets-truncated-…
Browse files Browse the repository at this point in the history
…on-save-when-quota-is-exceeded

don't alter file when there is not enough free space
  • Loading branch information
grnd-alt authored Apr 11, 2024
2 parents 77efd63 + b72d576 commit f3644e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,13 @@ public function putFile($fileId,

$content = fopen('php://input', 'rb');

$freespace = $file->getParent()->getFreeSpace();
$contentLength = (int)$this->request->getHeader('Content-Length');

try {
if ($freespace >= 0 && $contentLength > $freespace) {
throw new \Exception('Not enough storage');
}
$this->wrappedFilesystemOperation($wopi, function () use ($file, $content) {
return $file->putContent($content);
});
Expand Down

0 comments on commit f3644e4

Please sign in to comment.