Skip to content

Commit

Permalink
Merge pull request #44332 from nextcloud/fix/fix-chunkupload-quota-check
Browse files Browse the repository at this point in the history
fix(dav): Fix quota check for chunk upload
  • Loading branch information
come-nc authored Apr 2, 2024
2 parents 1722739 + 01f59be commit 9aa7225
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 6 additions & 4 deletions apps/dav/lib/Connector/Sabre/QuotaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ public function getLength() {
}

$ocLength = $req->getHeader('OC-Total-Length');
if (is_numeric($length) && is_numeric($ocLength)) {
return max($length, $ocLength);
if (!is_numeric($ocLength)) {
return $length;
}

return $length;
if (!is_numeric($length)) {
return $ocLength;
}
return max($length, $ocLength);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* See the COPYING-README file.
*/
class QuotaPluginTest extends TestCase {

/** @var \Sabre\DAV\Server | \PHPUnit\Framework\MockObject\MockObject */
private $server;

Expand Down Expand Up @@ -149,8 +148,8 @@ public function lengthProvider() {
[null, ['CONTENT-LENGTH' => 'A']],
[1024, ['OC-TOTAL-LENGTH' => 'A', 'CONTENT-LENGTH' => '1024']],
[1024, ['OC-TOTAL-LENGTH' => 'A', 'X-EXPECTED-ENTITY-LENGTH' => '1024']],
[null, ['OC-TOTAL-LENGTH' => '2048', 'X-EXPECTED-ENTITY-LENGTH' => 'A']],
[null, ['OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => 'A']],
[2048, ['OC-TOTAL-LENGTH' => '2048', 'X-EXPECTED-ENTITY-LENGTH' => 'A']],
[2048, ['OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => 'A']],
];
}

Expand Down

0 comments on commit 9aa7225

Please sign in to comment.