-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31050 from owncloud/stable10-11c0712ea23070a62020…
…a5dd8b6407db259e5b0d [stable10] Backport all objectstore related changes
- Loading branch information
Showing
105 changed files
with
4,213 additions
and
1,432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2017, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\DAV\DAV; | ||
|
||
use OCA\DAV\Connector\Sabre\Exception\Forbidden; | ||
use OCA\DAV\Connector\Sabre\File; | ||
use OCA\DAV\Files\ICopySource; | ||
use OCP\Files\ForbiddenException; | ||
use OCP\Lock\ILockingProvider; | ||
use Sabre\DAV\IFile; | ||
use Sabre\DAV\Server; | ||
use Sabre\DAV\ServerPlugin; | ||
use Sabre\HTTP\RequestInterface; | ||
use Sabre\HTTP\ResponseInterface; | ||
|
||
/** | ||
* Class CopyPlugin - adds own implementation of the COPY method. | ||
* This is necessary because we don't want the target to be deleted before the move. | ||
* | ||
* Deleting the target will kill the versions which is the wrong behavior. | ||
* | ||
* @package OCA\DAV\DAV | ||
*/ | ||
class CopyPlugin extends ServerPlugin { | ||
|
||
/** @var Server */ | ||
private $server; | ||
|
||
/** | ||
* @param Server $server | ||
*/ | ||
function initialize(Server $server) { | ||
$this->server = $server; | ||
$server->on('method:COPY', [$this, 'httpCopy'], 90); | ||
} | ||
|
||
/** | ||
* WebDAV HTTP COPY method | ||
* | ||
* This method copies one uri to a different uri, and works much like the MOVE request | ||
* A lot of the actual request processing is done in getCopyMoveInfo | ||
* | ||
* @param RequestInterface $request | ||
* @param ResponseInterface $response | ||
* @return bool | ||
* @throws Forbidden | ||
*/ | ||
function httpCopy(RequestInterface $request, ResponseInterface $response) { | ||
|
||
try { | ||
|
||
$path = $request->getPath(); | ||
|
||
$copyInfo = $this->server->getCopyAndMoveInfo($request); | ||
$sourceNode = $this->server->tree->getNodeForPath($path); | ||
$destinationNode = $copyInfo['destinationNode']; | ||
if (!$copyInfo['destinationExists'] || !$destinationNode instanceof File || !$sourceNode instanceof IFile) { | ||
return true; | ||
} | ||
|
||
if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) return false; | ||
|
||
$copySuccess = false; | ||
if ($sourceNode instanceof ICopySource) { | ||
$copySuccess = $sourceNode->copy($destinationNode->getFileInfo()->getPath()); | ||
} | ||
if (!$copySuccess) { | ||
$destinationNode->acquireLock(ILockingProvider::LOCK_SHARED); | ||
$destinationNode->put($sourceNode->get()); | ||
$destinationNode->releaseLock(ILockingProvider::LOCK_SHARED); | ||
} | ||
|
||
$this->server->emit('afterBind', [$copyInfo['destination']]); | ||
|
||
$response->setHeader('Content-Length', '0'); | ||
$response->setStatus(204); | ||
|
||
// Sending back false will interrupt the event chain and tell the server | ||
// we've handled this method. | ||
return false; | ||
} catch (ForbiddenException $ex) { | ||
throw new Forbidden($ex->getMessage(), $ex->getRetry()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2017, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\DAV\Files; | ||
|
||
|
||
/** | ||
* Interface ICopySource | ||
* This interface allows special handling of copy operations based on the copy source. | ||
* This gives the developer the freedom to implement a more efficient copy operation. | ||
* | ||
* @package OCA\DAV\Files | ||
*/ | ||
interface ICopySource { | ||
|
||
/** | ||
* Copies the source to the given destination. | ||
* If the operation was not successful false is returned. | ||
* | ||
* @param string $destinationPath | ||
* @return boolean | ||
*/ | ||
public function copy($destinationPath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2017, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\DAV\Files; | ||
|
||
|
||
use OCP\Files\Node; | ||
|
||
interface IFileNode { | ||
|
||
/** | ||
* @return Node | ||
*/ | ||
public function getNode(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2017, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\DAV\Files; | ||
|
||
|
||
/** | ||
* Interface IProvidesAdditionalHeaders | ||
* This interface allows to add additional headers to the response | ||
* | ||
* @package OCA\DAV\Files | ||
*/ | ||
interface IProvidesAdditionalHeaders { | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getHeaders(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getContentDispositionFileName(); | ||
|
||
} |
Oops, something went wrong.