|
|
@@ -36,13 +36,16 @@ |
|
|
|
|
|
|
|
namespace OCA\DAV\Connector\Sabre; |
|
|
|
|
|
|
|
use OC\AppFramework\Http\Request; |
|
|
|
use OC\Files\Filesystem; |
|
|
|
use OC\Files\View; |
|
|
|
use OCA\DAV\Connector\Sabre\Exception\EntityTooLarge; |
|
|
|
use OCA\DAV\Connector\Sabre\Exception\FileLocked; |
|
|
|
use OCA\DAV\Connector\Sabre\Exception\Forbidden as DAVForbiddenException; |
|
|
|
use OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType; |
|
|
|
use OCP\Encryption\Exceptions\GenericEncryptionException; |
|
|
|
use OCP\Files\EntityTooLargeException; |
|
|
|
use OCP\Files\FileInfo; |
|
|
|
use OCP\Files\ForbiddenException; |
|
|
|
use OCP\Files\InvalidContentException; |
|
|
|
use OCP\Files\InvalidPathException; |
|
|
@@ -51,6 +54,7 @@ use OCP\Files\NotPermittedException; |
|
|
|
use OCP\Files\StorageNotAvailableException; |
|
|
|
use OCP\Lock\ILockingProvider; |
|
|
|
use OCP\Lock\LockedException; |
|
|
|
use OCP\Share\IManager; |
|
|
|
use Sabre\DAV\Exception; |
|
|
|
use Sabre\DAV\Exception\BadRequest; |
|
|
|
use Sabre\DAV\Exception\Forbidden; |
|
|
@@ -61,6 +65,26 @@ use Sabre\DAV\Exception\NotFound; |
|
|
|
|
|
|
|
class File extends Node implements IFile { |
|
|
|
|
|
|
|
protected $request; |
|
|
|
|
|
|
|
/** |
|
|
|
* Sets up the node, expects a full path name |
|
|
|
* |
|
|
|
* @param \OC\Files\View $view |
|
|
|
* @param \OCP\Files\FileInfo $info |
|
|
|
* @param \OCP\Share\IManager $shareManager |
|
|
|
* @param \OC\AppFramework\Http\Request $request |
|
|
|
*/ |
|
|
|
public function __construct(View $view, FileInfo $info, IManager $shareManager = null, Request $request = null) { |
|
|
|
parent::__construct($view, $info, $shareManager); |
|
|
|
|
|
|
|
if (isset($request)) { |
|
|
|
$this->request = $request; |
|
|
|
} else { |
|
|
|
$this->request = \OC::$server->getRequest(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Updates the data |
|
|
|
* |
|
|
@@ -208,9 +232,8 @@ class File extends Node implements IFile { |
|
|
|
} |
|
|
|
|
|
|
|
// allow sync clients to send the mtime along in a header |
|
|
|
$request = \OC::$server->getRequest(); |
|
|
|
if (isset($request->server['HTTP_X_OC_MTIME'])) { |
|
|
|
$mtime = $this->sanitizeMtime($request->server['HTTP_X_OC_MTIME']); |
|
|
|
if (isset($this->request->server['HTTP_X_OC_MTIME'])) { |
|
|
|
$mtime = $this->sanitizeMtime($this->request->server['HTTP_X_OC_MTIME']); |
|
|
|
if ($this->fileView->touch($this->path, $mtime)) { |
|
|
|
header('X-OC-MTime: accepted'); |
|
|
|
} |
|
|
@@ -222,8 +245,8 @@ class File extends Node implements IFile { |
|
|
|
|
|
|
|
$this->refreshInfo(); |
|
|
|
|
|
|
|
if (isset($request->server['HTTP_OC_CHECKSUM'])) { |
|
|
|
$checksum = trim($request->server['HTTP_OC_CHECKSUM']); |
|
|
|
if (isset($this->request->server['HTTP_OC_CHECKSUM'])) { |
|
|
|
$checksum = trim($this->request->server['HTTP_OC_CHECKSUM']); |
|
|
|
$this->fileView->putFileInfo($this->path, ['checksum' => $checksum]); |
|
|
|
$this->refreshInfo(); |
|
|
|
} else if ($this->getChecksum() !== null && $this->getChecksum() !== '') { |
|
|
@@ -466,9 +489,8 @@ class File extends Node implements IFile { |
|
|
|
} |
|
|
|
|
|
|
|
// allow sync clients to send the mtime along in a header |
|
|
|
$request = \OC::$server->getRequest(); |
|
|
|
if (isset($request->server['HTTP_X_OC_MTIME'])) { |
|
|
|
$mtime = $this->sanitizeMtime($request->server['HTTP_X_OC_MTIME']); |
|
|
|
if (isset($this->request->server['HTTP_X_OC_MTIME'])) { |
|
|
|
$mtime = $this->sanitizeMtime($this->request->server['HTTP_X_OC_MTIME']); |
|
|
|
if ($targetStorage->touch($targetInternalPath, $mtime)) { |
|
|
|
header('X-OC-MTime: accepted'); |
|
|
|
} |
|
|
@@ -484,8 +506,8 @@ class File extends Node implements IFile { |
|
|
|
// FIXME: should call refreshInfo but can't because $this->path is not the of the final file |
|
|
|
$info = $this->fileView->getFileInfo($targetPath); |
|
|
|
|
|
|
|
if (isset($request->server['HTTP_OC_CHECKSUM'])) { |
|
|
|
$checksum = trim($request->server['HTTP_OC_CHECKSUM']); |
|
|
|
if (isset($this->request->server['HTTP_OC_CHECKSUM'])) { |
|
|
|
$checksum = trim($this->request->server['HTTP_OC_CHECKSUM']); |
|
|
|
$this->fileView->putFileInfo($targetPath, ['checksum' => $checksum]); |
|
|
|
} else if ($info->getChecksum() !== null && $info->getChecksum() !== '') { |
|
|
|
$this->fileView->putFileInfo($this->path, ['checksum' => '']); |