aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2021-04-23 13:20:08 +0200
committerGitHub <noreply@github.com>2021-04-23 13:20:08 +0200
commit1a1ea4e3ea1c9254ec7f42b952dd863b96af046e (patch)
tree1b0a21847a47eeb6064ece1bbb557c4ad54fc9b8 /apps
parent513aba623ec02667629b8eb234507cd0feb3c4c3 (diff)
parent1722044992d8b8d5bcabcbd0b756f8564bf00d8a (diff)
downloadnextcloud-server-1a1ea4e3ea1c9254ec7f42b952dd863b96af046e.tar.gz
nextcloud-server-1a1ea4e3ea1c9254ec7f42b952dd863b96af046e.zip
Merge pull request #26717 from nextcloud/fix/copy-etag-node-not-found
Only set copy etag if the destination source can be found
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php9
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php14
2 files changed, 22 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php b/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
index 9d58b25aa5a..0da15c113ee 100644
--- a/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
@@ -25,6 +25,7 @@
namespace OCA\DAV\Connector\Sabre;
+use Sabre\DAV\Exception\NotFound;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
@@ -74,7 +75,13 @@ class CopyEtagHeaderPlugin extends \Sabre\DAV\ServerPlugin {
* @return void
*/
public function afterMove($source, $destination) {
- $node = $this->server->tree->getNodeForPath($destination);
+ try {
+ $node = $this->server->tree->getNodeForPath($destination);
+ } catch (NotFound $e) {
+ // Don't care
+ return;
+ }
+
if ($node instanceof File) {
$eTag = $node->getETag();
$this->server->httpResponse->setHeader('OC-ETag', $eTag);
diff --git a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php
index 487fb2b6285..010d8af5a66 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php
@@ -29,6 +29,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin;
use OCA\DAV\Connector\Sabre\File;
+use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Server;
use Sabre\DAV\Tree;
use Test\TestCase;
@@ -73,6 +74,19 @@ class CopyEtagHeaderPluginTest extends TestCase {
$this->assertNull($response->getHeader('OC-Etag'));
}
+ public function testAfterMoveNodeNotFound(): void {
+ $tree = $this->createMock(Tree::class);
+ $tree->expects(self::once())
+ ->method('getNodeForPath')
+ ->with('test.txt')
+ ->willThrowException(new NotFound());
+
+ $this->server->tree = $tree;
+ $this->plugin->afterMove('', 'test.txt');
+
+ // Nothing to assert, we are just testing if the exception is handled
+ }
+
public function testAfterMove() {
$node = $this->getMockBuilder(File::class)
->disableOriginalConstructor()