Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace OCA\DAV\Connector\Sabre;

use Sabre\DAV\Exception\NotFound;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;

Expand Down Expand Up @@ -74,7 +75,13 @@ public function afterMethod(RequestInterface $request, ResponseInterface $respon
* @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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

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;
Expand Down Expand Up @@ -73,6 +74,19 @@ public function testNoopWhenEmpty() {
$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()
Expand Down