* If the array is empty, all properties should be returned
*
* @param array $properties
- * @return void
+ * @return array
*/
public function getProperties($properties) {
$props = parent::getProperties($properties);
if (in_array(self::GETETAG_PROPERTYNAME, $properties) && !isset($props[self::GETETAG_PROPERTYNAME])) {
- $props[self::GETETAG_PROPERTYNAME]
- = OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
+ $props[self::GETETAG_PROPERTYNAME] = $this->getETagPropertyForPath($this->path);
}
return $props;
}
* @return string|null
*/
public function put($data) {
-
- if (\OC\Files\Filesystem::file_exists($this->path) &&
- !\OC\Files\Filesystem::isUpdatable($this->path)) {
+ $fs = $this->getFS();
+ if ($fs->file_exists($this->path) &&
+ !$fs->isUpdatable($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
}
if ($chunk_handler->isComplete()) {
$newPath = $this->path . '/' . $info['name'];
$chunk_handler->file_assemble($newPath);
- return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
+ return $this->getETagPropertyForPath($newPath);
}
return null;
// mark file as partial while uploading (ignored by the scanner)
$partpath = $this->path . '.part';
- $putOkay = \OC\Files\Filesystem::file_put_contents($partpath, $data);
+ $putOkay = $fs->file_put_contents($partpath, $data);
if ($putOkay === false) {
\OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR);
- \OC\Files\Filesystem::unlink($partpath);
+ $fs->unlink($partpath);
throw new Sabre_DAV_Exception();
}
if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
if (isset($_SERVER['CONTENT_LENGTH'])) {
$expected = $_SERVER['CONTENT_LENGTH'];
- $actual = \OC\Files\Filesystem::filesize($partpath);
+ $actual = $fs->filesize($partpath);
if ($actual != $expected) {
- \OC\Files\Filesystem::unlink($partpath);
+ $fs->unlink($partpath);
throw new Sabre_DAV_Exception_BadRequest(
'expected filesize ' . $expected . ' got ' . $actual);
}
}
// rename to correct path
- \OC\Files\Filesystem::rename($partpath, $this->path);
+ $fs->rename($partpath, $this->path);
// allow sync clients to send the mtime along in a header
$mtime = OC_Request::hasModificationTime();
if ($mtime !== false) {
- if(\OC\Files\Filesystem::touch($this->path, $mtime)) {
+ if($fs->touch($this->path, $mtime)) {
header('X-OC-MTime: accepted');
}
}
- return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
+ return $this->getETagPropertyForPath($this->path);
}
/**
*/
public static $ETagFunction = null;
+ /**
+ * is kept public to allow overwrite for unit testing
+ *
+ * @var \OC\Files\View
+ */
+ public $fileView;
+
/**
* The path to the current node
*
* @param string $path Path of the file
* @return string|null Returns null if the ETag can not effectively be determined
*/
- static public function getETagPropertyForPath($path) {
- $data = \OC\Files\Filesystem::getFileInfo($path);
+ protected function getETagPropertyForPath($path) {
+ $data = $this->getFS()->getFileInfo($path);
if (isset($data['etag'])) {
return '"'.$data['etag'].'"';
}
return null;
}
+ protected function getFS() {
+ if (is_null($this->fileView)) {
+ $this->fileView = \OC\Files\Filesystem::getView();
+ }
+ return $this->fileView;
+ }
}