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

Feature/29087 with dav layer #29281

Closed
wants to merge 5 commits into from
Closed
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
55 changes: 55 additions & 0 deletions apps/dav/lib/Meta/MetaFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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\Meta;


use OCP\Files\Folder;
use Sabre\DAV\Collection;
use Sabre\DAV\File;

class MetaFile extends File {

/** @var \OCP\Files\File */
private $file;

/**
* MetaFolder constructor.
*
* @param \OCP\Files\File $file
*/
public function __construct(\OCP\Files\File $file) {
$this->file = $file;
}

/**
* @inheritdoc
*/
function getName() {
return $this->file->getName();
}

public function get() {
// FIXME: use fopen and return the stream
return $this->file->getContent();
}
}
72 changes: 72 additions & 0 deletions apps/dav/lib/Meta/MetaFolder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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\Meta;


use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\Node;
use Sabre\DAV\Collection;

class MetaFolder extends Collection {

/** @var Folder */
private $folder;

/**
* MetaFolder constructor.
*
* @param Folder $folder
*/
public function __construct(Folder $folder) {
$this->folder = $folder;
}

/**
* @inheritdoc
*/
function getChildren() {
$nodes = $this->folder->getDirectoryListing();
return array_map(function($node) {
return static::nodeFactory($node);
}, $nodes);
}

/**
* @inheritdoc
*/
function getName() {
return $this->folder->getName();
}

public static function nodeFactory(Node $node) {
if ($node instanceof Folder) {
return new MetaFolder($node);
}
if ($node instanceof File) {
return new MetaFile($node);
}
throw new \InvalidArgumentException();
}

}
68 changes: 68 additions & 0 deletions apps/dav/lib/Meta/RootCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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\Meta;


use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use Sabre\DAV\Collection;
use Sabre\DAV\Exception\MethodNotAllowed;

class RootCollection extends Collection {

/** @var IRootFolder */
private $rootFolder;

/**
* RootCollection constructor.
*
* @param IRootFolder $rootFolder
*/
public function __construct(IRootFolder $rootFolder) {
$this->rootFolder = $rootFolder;
}

/**
* @inheritdoc
*/
public function getChild($name) {
$child = $this->rootFolder->get("meta/$name");
return MetaFolder::nodeFactory($child);
}

/**
* @inheritdoc
*/
function getChildren() {
throw new MethodNotAllowed('Listing members of this collection is disabled');
}

/**
* @inheritdoc
*/
function getName() {
return 'meta';
}
}
3 changes: 2 additions & 1 deletion apps/dav/lib/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public function __construct() {
$systemTagCollection,
$systemTagRelationsCollection,
$uploadCollection,
$avatarCollection
$avatarCollection,
new \OCA\DAV\Meta\RootCollection(\OC::$server->getRootFolder())
];

parent::__construct('root', $children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


use OCA\Federation\BackgroundJob\GetSharedSecret;
use OCA\Files_Sharing\Tests\TestCase;
use OCA\Federation\DbHandler;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http;
Expand All @@ -35,6 +34,7 @@
use OCP\Http\Client\IResponse;
use OCP\ILogger;
use OCP\IURLGenerator;
use Test\TestCase;

/**
* Class GetSharedSecretTest
Expand Down
1 change: 1 addition & 0 deletions apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ public static function getVersions($uid, $filename, $userFullPath = '') {
$versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'] . '/' . $filename);
$versions[$key]['name'] = $versionedFile;
$versions[$key]['size'] = $view->filesize($dir . '/' . $entryName);
$versions[$key]['storage_location'] = "$dir/$entryName";
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/private/AvatarManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public function getAvatar($userId) {
throw new \Exception('user does not exist');
}

$userId = $user->getUID();

$avatarsFolder = $this->getAvatarFolder($user);
return new Avatar($avatarsFolder, $this->l, $user, $this->logger);
}
Expand Down
Loading