summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Connector/Sabre/Directory.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-03-30 11:30:37 +0200
committerJoas Schilling <coding@schilljs.com>2017-04-26 15:46:38 +0200
commit7b6e4d0dd2dce40fcc7da9de2b7e49b26dfe1914 (patch)
tree84a9055b4904ce08acaff40bc5a0d6d481635676 /apps/dav/lib/Connector/Sabre/Directory.php
parentec8d7010e54138f87a5c17216b6863188db136a4 (diff)
downloadnextcloud-server-7b6e4d0dd2dce40fcc7da9de2b7e49b26dfe1914.tar.gz
nextcloud-server-7b6e4d0dd2dce40fcc7da9de2b7e49b26dfe1914.zip
Fix FutureFile MOVE to keep destination node
Sabre usually deletes the target node on MOVE before proceeding with the actual move operation. This fix prevents this to happen in case the source node is a FutureFile.
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/Directory.php')
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index ddf324ce851..9afa6367685 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -120,9 +120,9 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
// exit if we can't create a new file and we don't updatable existing file
- $info = \OC_FileChunking::decodeName($name);
+ $chunkInfo = \OC_FileChunking::decodeName($name);
if (!$this->fileView->isCreatable($this->path) &&
- !$this->fileView->isUpdatable($this->path . '/' . $info['name'])
+ !$this->fileView->isUpdatable($this->path . '/' . $chunkInfo['name'])
) {
throw new \Sabre\DAV\Exception\Forbidden();
}
@@ -137,8 +137,12 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
$this->fileView->verifyPath($this->path, $name);
$path = $this->fileView->getAbsolutePath($this->path) . '/' . $name;
- // using a dummy FileInfo is acceptable here since it will be refreshed after the put is complete
- $info = new \OC\Files\FileInfo($path, null, null, array(), null);
+ // in case the file already exists/overwriting
+ $info = $this->fileView->getFileInfo($this->path . '/' . $name);
+ if (!$info) {
+ // use a dummy FileInfo which is acceptable here since it will be refreshed after the put is complete
+ $info = new \OC\Files\FileInfo($path, null, null, [], null);
+ }
$node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
$node->acquireLock(ILockingProvider::LOCK_SHARED);
return $node->put($data);