aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-01-11 12:38:13 +0100
committerVincent Petry <pvince81@owncloud.com>2016-02-17 11:52:49 +0100
commit53eff9792f1ae5ece49dfe79b40d1d73ae530688 (patch)
tree72ae6ed17502d332dd4a539fc5699be05a11d49d /apps/dav/lib
parent7b0f83b616246c5274b551ab46b923b0989c464e (diff)
downloadnextcloud-server-53eff9792f1ae5ece49dfe79b40d1d73ae530688.tar.gz
nextcloud-server-53eff9792f1ae5ece49dfe79b40d1d73ae530688.zip
Check the quota on the actual file's storage in dav quota plugin
Fix quota plugin to use the correct file name when chunking When chunking, the file name is the compound name, so need to convert it to the correct final file name before doing the free space check. This ensures that in the case of shared files, the correct storage is used for the quota check.
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/connector/sabre/quotaplugin.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/apps/dav/lib/connector/sabre/quotaplugin.php b/apps/dav/lib/connector/sabre/quotaplugin.php
index a02827da499..b1c3bbfbbb9 100644
--- a/apps/dav/lib/connector/sabre/quotaplugin.php
+++ b/apps/dav/lib/connector/sabre/quotaplugin.php
@@ -95,12 +95,14 @@ class QuotaPlugin extends \Sabre\DAV\ServerPlugin {
$req = $this->server->httpRequest;
if ($req->getHeader('OC-Chunked')) {
$info = \OC_FileChunking::decodeName($newName);
- $chunkHandler = new \OC_FileChunking($info);
+ $chunkHandler = $this->getFileChunking($info);
// subtract the already uploaded size to see whether
// there is still enough space for the remaining chunks
$length -= $chunkHandler->getCurrentSize();
+ // use target file name for free space check in case of shared files
+ $uri = rtrim($parentUri, '/') . '/' . $info['name'];
}
- $freeSpace = $this->getFreeSpace($parentUri);
+ $freeSpace = $this->getFreeSpace($uri);
if ($freeSpace !== \OCP\Files\FileInfo::SPACE_UNKNOWN && $length > $freeSpace) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
@@ -111,6 +113,11 @@ class QuotaPlugin extends \Sabre\DAV\ServerPlugin {
return true;
}
+ public function getFileChunking($info) {
+ // FIXME: need a factory for better mocking support
+ return new \OC_FileChunking($info);
+ }
+
public function getLength() {
$req = $this->server->httpRequest;
$length = $req->getHeader('X-Expected-Entity-Length');
@@ -127,12 +134,12 @@ class QuotaPlugin extends \Sabre\DAV\ServerPlugin {
}
/**
- * @param string $parentUri
+ * @param string $uri
* @return mixed
*/
- public function getFreeSpace($parentUri) {
+ public function getFreeSpace($uri) {
try {
- $freeSpace = $this->view->free_space($parentUri);
+ $freeSpace = $this->view->free_space(ltrim($uri, '/'));
return $freeSpace;
} catch (\OCP\Files\StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());