Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Backport all objectstore related changes #31050

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
bd740f0
[stable10] Introducing Abstract base implementations for node api int…
DeepDiver1975 Oct 12, 2017
0487595
Adding meta data file tree to node api
DeepDiver1975 Oct 11, 2017
2414a52
Introducing IVersionedStorage
DeepDiver1975 Oct 12, 2017
69ccd10
Minimalistic implementation of versions integration - needs change in…
DeepDiver1975 Oct 12, 2017
e146095
Adding dav layer on top of the MetaNodes
DeepDiver1975 Oct 18, 2017
087ab5e
behat for feature 29087. DAV meta endpoint
peterprochaska Oct 25, 2017
b6136da
Adding etag, mtime and mimetype to versions
DeepDiver1975 Oct 30, 2017
88fb37f
Allow decryption of versions when being accessed by getContentOfVersi…
DeepDiver1975 Oct 30, 2017
745a3ff
COPY does not delete the destination and by that allows to keep versi…
DeepDiver1975 Oct 19, 2017
3fcff1d
Add copy method to the files client
DeepDiver1975 Oct 16, 2017
4bb874c
Migrate files versions frontend to use dav for versions
DeepDiver1975 Oct 16, 2017
bef9053
Enhance tests
DeepDiver1975 Nov 9, 2017
5bc65bc
Add Content-Disposition header to GET responses of versions
DeepDiver1975 Nov 10, 2017
af373e6
Fix version restore of shared and encrypted external storage
DeepDiver1975 Nov 15, 2017
f2bec85
Extract ObjectStoreTests into class of it's own
DeepDiver1975 Nov 21, 2017
1ead426
Add versioning to objectstore
DeepDiver1975 Nov 17, 2017
73a54c1
Move thumb nailing to the next level ....
DeepDiver1975 Sep 18, 2017
d69e53d
Introduce \OCP\Preview\IProvider2 with the new interface
DeepDiver1975 Oct 20, 2017
541178b
Files app uses dav preview endpoint
DeepDiver1975 Oct 20, 2017
d810963
Fix preview provider tests
DeepDiver1975 Oct 20, 2017
b09846b
Use dav preview for version preview
DeepDiver1975 Oct 26, 2017
7fe9293
fix preview url, remove preceeding /
butonic Jan 17, 2018
d7bf62b
remove no longer existing preview route
DeepDiver1975 Jan 24, 2018
7458800
Use IPreviewNode to fix trashbin thumbnails - fixes #30189
DeepDiver1975 Jan 19, 2018
73779d5
Testing /remote.php/dav/meta/$fileId/v
DeepDiver1975 Nov 20, 2017
ac71055
Fix version on public API
DeepDiver1975 Apr 9, 2018
a479c87
Fix VersioningTest - cherry-pick was screwed up
DeepDiver1975 Apr 9, 2018
3eff550
Adding davtest.txt - got lost on cherry-pick
DeepDiver1975 Apr 10, 2018
d98d5e4
Fixing PreviewManagerTest
DeepDiver1975 Apr 26, 2018
fb5bdfc
sharing-v1.feature: not test on storage_id
DeepDiver1975 Apr 27, 2018
1760283
federated.feature: not test on storage_id
DeepDiver1975 Apr 27, 2018
374afc1
the destination node has to be locked before written to - fixed objec…
DeepDiver1975 Apr 27, 2018
e3f4005
Delete home storage properly for object store as well
DeepDiver1975 Apr 30, 2018
0712310
Add storage detection of objectstore home storages
DeepDiver1975 May 2, 2018
3002d1c
DAV permissions for objectstore contain M - because objectstores are …
DeepDiver1975 May 2, 2018
ee392c1
Skip scenario on objectstore
DeepDiver1975 May 2, 2018
39329d3
Trashbin::undelete - assert that there was no error
DeepDiver1975 May 2, 2018
6f4e3cf
No need to update checksums if none is computed
DeepDiver1975 May 2, 2018
a5823ca
QueryBuilder::execute should live inside the if statement
DeepDiver1975 May 2, 2018
9f905e7
After writing a file in copyr the folder size shall be corrected - th…
DeepDiver1975 May 2, 2018
a0fb9ae
Add login of test user to enforce storage creation
DeepDiver1975 May 18, 2018
09f5587
Fix acceptance api tests - don't test for storage_id
DeepDiver1975 May 18, 2018
807c82d
fclose the target file, not the object, when skeleton is copied
May 30, 2018
d228be1
API test for restoring version of shared file
paurakhsharma May 29, 2018
8c5186b
Login test user to enforce storage creation
DeepDiver1975 Jun 4, 2018
0635d85
fixes #31655 - don't delete the source files when generating thumbnails
DeepDiver1975 Jun 6, 2018
313bcf3
Add contentOfFileShouldBe acceptance test scripts and refactor
phil-davis Jun 1, 2018
43402ca
More API test for file versions
paurakhsharma Jun 4, 2018
a4b7ee6
Add version restore tests when sharee has moved the shared folder or …
phil-davis Jun 7, 2018
79a95da
Remove extra copies of dav-versions.feature and davtest.txt
phil-davis Jun 11, 2018
94c18a3
Fix FeatureContext extends \rdx\behatvars\BehatVariablesContext
phil-davis Jun 11, 2018
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
10 changes: 9 additions & 1 deletion apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
use OCA\DAV\Connector\Sabre\Exception\Forbidden as DAVForbiddenException;
use OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType;
use OCA\DAV\Files\IFileNode;
use OCP\Encryption\Exceptions\GenericEncryptionException;
use OCP\Events\EventEmitterTrait;
use OCP\Files\EntityTooLargeException;
Expand All @@ -61,7 +62,7 @@
use Sabre\DAV\IFile;
use Symfony\Component\EventDispatcher\GenericEvent;

class File extends Node implements IFile {
class File extends Node implements IFile, IFileNode {

use EventEmitterTrait;
protected $request;
Expand Down Expand Up @@ -714,4 +715,11 @@ public function getChecksum($algo = null) {
protected function header($string) {
\header($string);
}

/**
* @return \OCP\Files\Node
*/
public function getNode() {
return \OC::$server->getRootFolder()->get($this->getFileInfo()->getPath());
}
}
16 changes: 14 additions & 2 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
namespace OCA\DAV\Connector\Sabre;

use OC\AppFramework\Http\Request;
use OCA\DAV\Files\IProvidesAdditionalHeaders;
use OCA\DAV\Meta\MetaFile;
use OCP\Files\ForbiddenException;
use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
Expand Down Expand Up @@ -231,15 +233,18 @@ function httpGet(RequestInterface $request, ResponseInterface $response) {
// adds a 'Content-Disposition: attachment' header
if ($this->downloadAttachment) {
$filename = $node->getName();
if ($node instanceof IProvidesAdditionalHeaders) {
$filename = $node->getContentDispositionFileName();
}
if ($this->request->isUserAgent(
[
Request::USER_AGENT_IE,
Request::USER_AGENT_ANDROID_MOBILE_CHROME,
Request::USER_AGENT_FREEBOX,
])) {
$response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"');
$response->setHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"');
} else {
$response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename)
$response->setHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename)
. '; filename="' . rawurlencode($filename) . '"');
}
}
Expand All @@ -255,6 +260,13 @@ function httpGet(RequestInterface $request, ResponseInterface $response) {
// cause memory problems in the nginx process.
$response->addHeader('X-Accel-Buffering', 'no');
}

if ($node instanceof IProvidesAdditionalHeaders) {
$headers = $node->getHeaders();
if (is_array($headers)) {
$response->addHeaders($headers);
}
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ public function changeLock($type) {
$this->fileView->changeLock($this->path, $type);
}

/**
* @return \OCP\Files\FileInfo
*/
public function getFileInfo() {
return $this->info;
}
Expand Down
3 changes: 3 additions & 0 deletions apps/dav/lib/Connector/Sabre/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace OCA\DAV\Connector\Sabre;

use OCA\DAV\DAV\CopyPlugin;

/**
* Class \OCA\DAV\Connector\Sabre\Server
*
Expand All @@ -41,5 +43,6 @@ public function __construct($treeOrNode = null) {
parent::__construct($treeOrNode);
self::$exposeVersion = false;
$this->enablePropfindDepthInfinity = true;
$this->addPlugin(new CopyPlugin());
}
}
106 changes: 106 additions & 0 deletions apps/dav/lib/DAV/CopyPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
/**
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @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());
}
}

}
43 changes: 43 additions & 0 deletions apps/dav/lib/Files/ICopySource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @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);
}
35 changes: 35 additions & 0 deletions apps/dav/lib/Files/IFileNode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @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();

}
44 changes: 44 additions & 0 deletions apps/dav/lib/Files/IProvidesAdditionalHeaders.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @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();

}
Loading