# Task NEX-243 - Add a check to handle the negative cases in quota

Project: Stream Nextcloud app "OpenProject Integration"
Status: closed
URL: https://community.openproject.org/work_packages/NEX-243

## Details

| Attribute | Value |
| --- | --- |
| Assignee | Swikriti Tripathi |
| Date |  |
| Priority | Medium |
| Target versions | Nextcloud Integration 2.3.0 |
| Category |  |
| Labels |  |

## Description

Currently we're checking quota like this

``` php
$freeSpace = $folderNode->getFreeSpace();

// this is also true if we try to overwrite
// to overwrite a file we need enough free quota for the new data
// otherwise `putContent()` fails
if ($directUploadFile['size'] > $freeSpace) {
	throw new NotEnoughSpaceException('insufficient quota');
}
```

But since there's a possibility that the function `getFreeSpace` might return a negative

<https://github.com/nextcloud/server/blob/b1abc57c07a61b5a0557395d86c3e31486a96c23/lib/public/Files/FileInfo.php#L52>

<https://github.com/nextcloud/server/blob/b1abc57c07a61b5a0557395d86c3e31486a96c23/lib/public/Files/FileInfo.php#L57>

<https://github.com/nextcloud/server/blob/b1abc57c07a61b5a0557395d86c3e31486a96c23/lib/public/Files/FileInfo.php#L62>

So treat a negative return as a `unlimited_space`
