summaryrefslogtreecommitdiffstats
path: root/lib/private/connector/sabre/aborteduploaddetectionplugin.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-02-25 16:23:09 +0100
committerRobin Appelman <icewind@owncloud.com>2014-02-25 16:23:09 +0100
commit3a21755963d8d9897a48ab58292345c0b710e239 (patch)
treef6b8fd3065a03f2c5627b4f0d89c4b51d69c5c42 /lib/private/connector/sabre/aborteduploaddetectionplugin.php
parent9b4af31bac977cb788a6f4a013d32ba0a21437f0 (diff)
downloadnextcloud-server-3a21755963d8d9897a48ab58292345c0b710e239.tar.gz
nextcloud-server-3a21755963d8d9897a48ab58292345c0b710e239.zip
Pass the filesystem view as argument in the sabredav connectors and use the fileinfo object
Diffstat (limited to 'lib/private/connector/sabre/aborteduploaddetectionplugin.php')
-rw-r--r--lib/private/connector/sabre/aborteduploaddetectionplugin.php33
1 files changed, 12 insertions, 21 deletions
diff --git a/lib/private/connector/sabre/aborteduploaddetectionplugin.php b/lib/private/connector/sabre/aborteduploaddetectionplugin.php
index ad759d1d84a..1a092a59a82 100644
--- a/lib/private/connector/sabre/aborteduploaddetectionplugin.php
+++ b/lib/private/connector/sabre/aborteduploaddetectionplugin.php
@@ -22,11 +22,16 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl
private $server;
/**
- * is kept public to allow overwrite for unit testing
- *
* @var \OC\Files\View
*/
- public $fileView;
+ private $fileView;
+
+ /**
+ * @param \OC\Files\View $view
+ */
+ public function __construct($view) {
+ $this->fileView = $view;
+ }
/**
* This initializes the plugin.
@@ -55,7 +60,7 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl
// we should only react on PUT which is used for upload
// e.g. with LOCK this will not work, but LOCK uses createFile() as well
- if ($this->server->httpRequest->getMethod() !== 'PUT' ) {
+ if ($this->server->httpRequest->getMethod() !== 'PUT') {
return;
}
@@ -70,9 +75,9 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl
if (!$expected) {
return;
}
- $actual = $this->getFileView()->filesize($filePath);
+ $actual = $this->fileView->filesize($filePath);
if ($actual != $expected) {
- $this->getFileView()->unlink($filePath);
+ $this->fileView->unlink($filePath);
throw new Sabre_DAV_Exception_BadRequest('expected filesize ' . $expected . ' got ' . $actual);
}
@@ -81,8 +86,7 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl
/**
* @return string
*/
- public function getLength()
- {
+ public function getLength() {
$req = $this->server->httpRequest;
$length = $req->getHeader('X-Expected-Entity-Length');
if (!$length) {
@@ -91,17 +95,4 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl
return $length;
}
-
- /**
- * @return \OC\Files\View
- */
- public function getFileView()
- {
- if (is_null($this->fileView)) {
- // initialize fileView
- $this->fileView = \OC\Files\Filesystem::getView();
- }
-
- return $this->fileView;
- }
}