diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-07-03 19:49:25 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-05-30 16:10:30 +0200 |
commit | 6f346b4b1f4512668e631ac57e71fac9061bc5fe (patch) | |
tree | e9535788947481ffc10af76bc087afdba4fe9371 | |
parent | a76498f24509700a34ae20fdf4ad67eb791a9298 (diff) | |
download | nextcloud-server-6f346b4b1f4512668e631ac57e71fac9061bc5fe.tar.gz nextcloud-server-6f346b4b1f4512668e631ac57e71fac9061bc5fe.zip |
Fix webdav destination header when overwriting folders
The trailing slash is needed when talking to Apache's mod_dav server
-rw-r--r-- | lib/private/Files/Storage/DAV.php | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 04910ece684..4713eb86fc0 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -506,13 +506,18 @@ class DAV extends Common { $path1 = $this->cleanPath($path1); $path2 = $this->cleanPath($path2); try { + // overwrite directory ? + if ($this->is_dir($path2)) { + // needs trailing slash in destination + $path2 = rtrim($path2, '/') . '/'; + } $this->client->request( 'MOVE', $this->encodePath($path1), null, - array( - 'Destination' => $this->createBaseUri() . $this->encodePath($path2) - ) + [ + 'Destination' => $this->createBaseUri() . $this->encodePath($path2), + ] ); $this->statCache->clear($path1 . '/'); $this->statCache->clear($path2 . '/'); @@ -530,10 +535,22 @@ class DAV extends Common { /** {@inheritdoc} */ public function copy($path1, $path2) { $this->init(); - $path1 = $this->encodePath($this->cleanPath($path1)); - $path2 = $this->createBaseUri() . $this->encodePath($this->cleanPath($path2)); + $path1 = $this->cleanPath($path1); + $path2 = $this->cleanPath($path2); try { - $this->client->request('COPY', $path1, null, array('Destination' => $path2)); + // overwrite directory ? + if ($this->is_dir($path2)) { + // needs trailing slash in destination + $path2 = rtrim($path2, '/') . '/'; + } + $this->client->request( + 'COPY', + $this->encodePath($path1), + null, + [ + 'Destination' => $this->createBaseUri() . $this->encodePath($path2), + ] + ); $this->statCache->clear($path2 . '/'); $this->statCache->set($path2, true); $this->removeCachedFile($path2); |