summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------3rdparty0
-rw-r--r--apps/dav/appinfo/application.php15
-rw-r--r--apps/dav/appinfo/info.xml2
-rw-r--r--apps/dav/appinfo/install.php1
-rw-r--r--apps/dav/appinfo/update.php1
-rw-r--r--apps/dav/lib/connector/sabre/file.php4
-rw-r--r--apps/dav/lib/connector/sabre/serverfactory.php6
-rw-r--r--apps/dav/lib/connector/sabre/sharesplugin.php176
-rw-r--r--apps/dav/lib/connector/sabre/sharetypelist.php87
-rw-r--r--apps/dav/tests/unit/connector/sabre/file.php69
-rw-r--r--apps/dav/tests/unit/connector/sabre/sharesplugin.php257
-rw-r--r--apps/files/appinfo/application.php4
-rw-r--r--apps/files/controller/apicontroller.php54
-rw-r--r--apps/files/service/tagservice.php13
-rw-r--r--apps/files/tests/controller/apicontrollertest.php56
-rw-r--r--apps/files_external/3rdparty/.gitignore1
-rw-r--r--apps/files_external/3rdparty/composer.json4
-rw-r--r--apps/files_external/3rdparty/composer.lock29
-rw-r--r--apps/files_external/3rdparty/composer/ClassLoader.php8
-rw-r--r--apps/files_external/3rdparty/composer/autoload_classmap.php19
-rw-r--r--apps/files_external/3rdparty/composer/autoload_real.php15
-rw-r--r--apps/files_external/3rdparty/composer/installed.json29
-rw-r--r--apps/files_external/3rdparty/icewind/smb/README.md2
-rw-r--r--apps/files_external/3rdparty/icewind/smb/composer.json2
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/NativeShare.php10
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/NativeStream.php19
-rw-r--r--apps/files_external/3rdparty/icewind/streams-dummy/composer.json7
-rw-r--r--apps/files_external/3rdparty/icewind/streams/.travis.yml7
-rw-r--r--apps/files_external/3rdparty/icewind/streams/LICENCE21
-rw-r--r--apps/files_external/3rdparty/icewind/streams/README.md1
-rw-r--r--apps/files_external/3rdparty/icewind/streams/composer.json3
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php67
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/DirectoryFilter.php60
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/DirectoryWrapper.php88
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/File.php2
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/IteratorDirectory.php4
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/NullWrapper.php15
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/Path.php104
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/RetryWrapper.php66
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/SeekableWrapper.php92
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/Url.php64
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/UrlCallBack.php121
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/Wrapper.php31
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php72
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php130
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php59
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php105
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php9
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml6
-rw-r--r--apps/files_external/lib/google.php57
-rw-r--r--apps/files_sharing/js/share.js57
-rw-r--r--apps/files_sharing/js/sharedfilelist.js10
-rw-r--r--apps/files_sharing/tests/js/shareSpec.js33
-rw-r--r--build/integration/features/bootstrap/WebDav.php53
-rw-r--r--build/integration/features/webdav-related.feature73
-rw-r--r--core/js/systemtags/systemtagsinputfield.js4
-rw-r--r--core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js9
-rw-r--r--lib/private/filechunking.php48
58 files changed, 1760 insertions, 601 deletions
diff --git a/3rdparty b/3rdparty
-Subproject 0ee67806d6082675541c77d79b3f494d760e2c2
+Subproject ec111b90c429356dd99d7944d40478eb642a22f
diff --git a/apps/dav/appinfo/application.php b/apps/dav/appinfo/application.php
index 1dae3d4efbf..d06daf97f54 100644
--- a/apps/dav/appinfo/application.php
+++ b/apps/dav/appinfo/application.php
@@ -210,4 +210,19 @@ class Application extends App {
$this->getContainer()->getServer()->getLogger()->logException($ex);
}
}
+
+ public function generateBirthdays() {
+ try {
+ /** @var BirthdayService $migration */
+ $migration = $this->getContainer()->query('BirthdayService');
+ $userManager = $this->getContainer()->getServer()->getUserManager();
+
+ $userManager->callForAllUsers(function($user) use($migration) {
+ /** @var IUser $user */
+ $migration->syncUser($user->getUID());
+ });
+ } catch (\Exception $ex) {
+ $this->getContainer()->getServer()->getLogger()->logException($ex);
+ }
+ }
}
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml
index 4f1e805d99e..82d0f7cf8a1 100644
--- a/apps/dav/appinfo/info.xml
+++ b/apps/dav/appinfo/info.xml
@@ -5,7 +5,7 @@
<description>ownCloud WebDAV endpoint</description>
<licence>AGPL</licence>
<author>owncloud.org</author>
- <version>0.2.1</version>
+ <version>0.2.2</version>
<default_enable/>
<types>
<filesystem/>
diff --git a/apps/dav/appinfo/install.php b/apps/dav/appinfo/install.php
index a7a3220b90f..dc5ae39226e 100644
--- a/apps/dav/appinfo/install.php
+++ b/apps/dav/appinfo/install.php
@@ -25,3 +25,4 @@ $app = new Application();
$app->setupCron();
$app->migrateAddressbooks();
$app->migrateCalendars();
+$app->generateBirthdays();
diff --git a/apps/dav/appinfo/update.php b/apps/dav/appinfo/update.php
index aaa36052cd2..fbd41d25f49 100644
--- a/apps/dav/appinfo/update.php
+++ b/apps/dav/appinfo/update.php
@@ -23,3 +23,4 @@ use OCA\Dav\AppInfo\Application;
$app = new Application();
$app->setupCron();
+$app->generateBirthdays();
diff --git a/apps/dav/lib/connector/sabre/file.php b/apps/dav/lib/connector/sabre/file.php
index 59b3a6e7483..6b698c6e5a9 100644
--- a/apps/dav/lib/connector/sabre/file.php
+++ b/apps/dav/lib/connector/sabre/file.php
@@ -433,7 +433,7 @@ class File extends Node implements IFile {
list($partStorage, $partInternalPath) = $this->fileView->resolvePath($partFile);
- $chunk_handler->file_assemble($partStorage, $partInternalPath, $this->fileView->getAbsolutePath($targetPath));
+ $chunk_handler->file_assemble($partStorage, $partInternalPath);
// here is the final atomic rename
$renameOkay = $targetStorage->moveFromStorage($partStorage, $partInternalPath, $targetInternalPath);
@@ -452,7 +452,7 @@ class File extends Node implements IFile {
}
} else {
// assemble directly into the final file
- $chunk_handler->file_assemble($targetStorage, $targetInternalPath, $this->fileView->getAbsolutePath($targetPath));
+ $chunk_handler->file_assemble($targetStorage, $targetInternalPath);
}
// allow sync clients to send the mtime along in a header
diff --git a/apps/dav/lib/connector/sabre/serverfactory.php b/apps/dav/lib/connector/sabre/serverfactory.php
index 6ccec0bc0e8..080f889ae71 100644
--- a/apps/dav/lib/connector/sabre/serverfactory.php
+++ b/apps/dav/lib/connector/sabre/serverfactory.php
@@ -137,6 +137,12 @@ class ServerFactory {
if($this->userSession->isLoggedIn()) {
$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
+ $server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
+ $objectTree,
+ $this->userSession,
+ $userFolder,
+ \OC::$server->getShareManager()
+ ));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
$objectTree,
diff --git a/apps/dav/lib/connector/sabre/sharesplugin.php b/apps/dav/lib/connector/sabre/sharesplugin.php
new file mode 100644
index 00000000000..f75c1378718
--- /dev/null
+++ b/apps/dav/lib/connector/sabre/sharesplugin.php
@@ -0,0 +1,176 @@
+<?php
+/**
+ * @author Vincent Petry <pvince81@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @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\Connector\Sabre;
+
+use \Sabre\DAV\PropFind;
+use \Sabre\DAV\PropPatch;
+use OCP\IUserSession;
+use OCP\Share\IShare;
+use OCA\DAV\Connector\Sabre\ShareTypeList;
+
+/**
+ * Sabre Plugin to provide share-related properties
+ */
+class SharesPlugin extends \Sabre\DAV\ServerPlugin {
+
+ const NS_OWNCLOUD = 'http://owncloud.org/ns';
+ const SHARETYPES_PROPERTYNAME = '{http://owncloud.org/ns}share-types';
+
+ /**
+ * Reference to main server object
+ *
+ * @var \Sabre\DAV\Server
+ */
+ private $server;
+
+ /**
+ * @var \OCP\Share\IManager
+ */
+ private $shareManager;
+
+ /**
+ * @var \Sabre\DAV\Tree
+ */
+ private $tree;
+
+ /**
+ * @var string
+ */
+ private $userId;
+
+ /**
+ * @var \OCP\Files\Folder
+ */
+ private $userFolder;
+
+ /**
+ * @var IShare[]
+ */
+ private $cachedShareTypes;
+
+ /**
+ * @param \Sabre\DAV\Tree $tree tree
+ * @param IUserSession $userSession user session
+ * @param \OCP\Files\Folder $userFolder user home folder
+ * @param \OCP\Share\IManager $shareManager share manager
+ */
+ public function __construct(
+ \Sabre\DAV\Tree $tree,
+ IUserSession $userSession,
+ \OCP\Files\Folder $userFolder,
+ \OCP\Share\IManager $shareManager
+ ) {
+ $this->tree = $tree;
+ $this->shareManager = $shareManager;
+ $this->userFolder = $userFolder;
+ $this->userId = $userSession->getUser()->getUID();
+ $this->cachedShareTypes = [];
+ }
+
+ /**
+ * This initializes the plugin.
+ *
+ * This function is called by \Sabre\DAV\Server, after
+ * addPlugin is called.
+ *
+ * This method should set up the required event subscriptions.
+ *
+ * @param \Sabre\DAV\Server $server
+ */
+ public function initialize(\Sabre\DAV\Server $server) {
+ $server->xml->namespacesMap[self::NS_OWNCLOUD] = 'oc';
+ $server->xml->elementMap[self::SHARETYPES_PROPERTYNAME] = 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList';
+ $server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
+
+ $this->server = $server;
+ $this->server->on('propFind', array($this, 'handleGetProperties'));
+ }
+
+ /**
+ * Return a list of share types for outgoing shares
+ *
+ * @param \OCP\Files\Node $node file node
+ *
+ * @return int[] array of share types
+ */
+ private function getShareTypes(\OCP\Files\Node $node) {
+ $shareTypes = [];
+ $requestedShareTypes = [
+ \OCP\Share::SHARE_TYPE_USER,
+ \OCP\Share::SHARE_TYPE_GROUP,
+ \OCP\Share::SHARE_TYPE_LINK
+ ];
+ foreach ($requestedShareTypes as $requestedShareType) {
+ // one of each type is enough to find out about the types
+ $shares = $this->shareManager->getSharesBy(
+ $this->userId,
+ $requestedShareType,
+ $node,
+ false,
+ 1
+ );
+ if (!empty($shares)) {
+ $shareTypes[] = $requestedShareType;
+ }
+ }
+ return $shareTypes;
+ }
+
+ /**
+ * Adds shares to propfind response
+ *
+ * @param PropFind $propFind propfind object
+ * @param \Sabre\DAV\INode $sabreNode sabre node
+ */
+ public function handleGetProperties(
+ PropFind $propFind,
+ \Sabre\DAV\INode $sabreNode
+ ) {
+ if (!($sabreNode instanceof \OCA\DAV\Connector\Sabre\Node)) {
+ return;
+ }
+
+ // need prefetch ?
+ if ($sabreNode instanceof \OCA\DAV\Connector\Sabre\Directory
+ && $propFind->getDepth() !== 0
+ && !is_null($propFind->getStatus(self::SHARETYPES_PROPERTYNAME))
+ ) {
+ $folderNode = $this->userFolder->get($propFind->getPath());
+ $children = $folderNode->getDirectoryListing();
+
+ $this->cachedShareTypes[$folderNode->getId()] = $this->getShareTypes($folderNode);
+ foreach ($children as $childNode) {
+ $this->cachedShareTypes[$childNode->getId()] = $this->getShareTypes($childNode);
+ }
+ }
+
+ $propFind->handle(self::SHARETYPES_PROPERTYNAME, function() use ($sabreNode) {
+ if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
+ $shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
+ } else {
+ $node = $this->userFolder->get($sabreNode->getPath());
+ $shareTypes = $this->getShareTypes($node);
+ }
+
+ return new ShareTypeList($shareTypes);
+ });
+ }
+}
diff --git a/apps/dav/lib/connector/sabre/sharetypelist.php b/apps/dav/lib/connector/sabre/sharetypelist.php
new file mode 100644
index 00000000000..763586412ad
--- /dev/null
+++ b/apps/dav/lib/connector/sabre/sharetypelist.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * @author Vincent Petry <pvince81@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @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\Connector\Sabre;
+
+use Sabre\Xml\Element;
+use Sabre\Xml\Reader;
+use Sabre\Xml\Writer;
+
+/**
+ * ShareTypeList property
+ *
+ * This property contains multiple "share-type" elements, each containing a share type.
+ */
+class ShareTypeList implements Element {
+ const NS_OWNCLOUD = 'http://owncloud.org/ns';
+
+ /**
+ * Share types
+ *
+ * @var int[]
+ */
+ private $shareTypes;
+
+ /**
+ * @param int[] $shareTypes
+ */
+ public function __construct($shareTypes) {
+ $this->shareTypes = $shareTypes;
+ }
+
+ /**
+ * Returns the share types
+ *
+ * @return int[]
+ */
+ public function getShareTypes() {
+ return $this->shareTypes;
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * @param Reader $reader
+ * @return mixed
+ */
+ static function xmlDeserialize(Reader $reader) {
+ $shareTypes = [];
+
+ foreach ($reader->parseInnerTree() as $elem) {
+ if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
+ $shareTypes[] = (int)$elem['value'];
+ }
+ }
+ return new self($shareTypes);
+ }
+
+ /**
+ * The xmlSerialize metod is called during xml writing.
+ *
+ * @param Writer $writer
+ * @return void
+ */
+ function xmlSerialize(Writer $writer) {
+ foreach ($this->shareTypes as $shareType) {
+ $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
+ }
+ }
+}
diff --git a/apps/dav/tests/unit/connector/sabre/file.php b/apps/dav/tests/unit/connector/sabre/file.php
index 8bbef225483..eab7ece159c 100644
--- a/apps/dav/tests/unit/connector/sabre/file.php
+++ b/apps/dav/tests/unit/connector/sabre/file.php
@@ -422,6 +422,75 @@ class File extends \Test\TestCase {
);
}
+ /**
+ * Test that putting a file with chunks triggers create hooks
+ */
+ public function testPutChunkedFileTriggersHooks() {
+ HookHelper::setUpHooks();
+
+ $_SERVER['HTTP_OC_CHUNKED'] = true;
+ $this->assertNull($this->doPut('/foo.txt-chunking-12345-2-0'));
+ $this->assertNotEmpty($this->doPut('/foo.txt-chunking-12345-2-1'));
+
+ $this->assertCount(4, HookHelper::$hookCalls);
+ $this->assertHookCall(
+ HookHelper::$hookCalls[0],
+ Filesystem::signal_create,
+ '/foo.txt'
+ );
+ $this->assertHookCall(
+ HookHelper::$hookCalls[1],
+ Filesystem::signal_write,
+ '/foo.txt'
+ );
+ $this->assertHookCall(
+ HookHelper::$hookCalls[2],
+ Filesystem::signal_post_create,
+ '/foo.txt'
+ );
+ $this->assertHookCall(
+ HookHelper::$hookCalls[3],
+ Filesystem::signal_post_write,
+ '/foo.txt'
+ );
+ }
+
+ /**
+ * Test that putting a chunked file triggers update hooks
+ */
+ public function testPutOverwriteChunkedFileTriggersHooks() {
+ $view = \OC\Files\Filesystem::getView();
+ $view->file_put_contents('/foo.txt', 'some content that will be replaced');
+
+ HookHelper::setUpHooks();
+
+ $_SERVER['HTTP_OC_CHUNKED'] = true;
+ $this->assertNull($this->doPut('/foo.txt-chunking-12345-2-0'));
+ $this->assertNotEmpty($this->doPut('/foo.txt-chunking-12345-2-1'));
+
+ $this->assertCount(4, HookHelper::$hookCalls);
+ $this->assertHookCall(
+ HookHelper::$hookCalls[0],
+ Filesystem::signal_update,
+ '/foo.txt'
+ );
+ $this->assertHookCall(
+ HookHelper::$hookCalls[1],
+ Filesystem::signal_write,
+ '/foo.txt'
+ );
+ $this->assertHookCall(
+ HookHelper::$hookCalls[2],
+ Filesystem::signal_post_update,
+ '/foo.txt'
+ );
+ $this->assertHookCall(
+ HookHelper::$hookCalls[3],
+ Filesystem::signal_post_write,
+ '/foo.txt'
+ );
+ }
+
public static function cancellingHook($params) {
self::$hookCalls[] = array(
'signal' => Filesystem::signal_post_create,
diff --git a/apps/dav/tests/unit/connector/sabre/sharesplugin.php b/apps/dav/tests/unit/connector/sabre/sharesplugin.php
new file mode 100644
index 00000000000..9a1c6eec507
--- /dev/null
+++ b/apps/dav/tests/unit/connector/sabre/sharesplugin.php
@@ -0,0 +1,257 @@
+<?php
+/**
+ * @author Vincent Petry <pvince81@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @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\Tests\Unit\Connector\Sabre;
+
+class SharesPlugin extends \Test\TestCase {
+
+ const SHARETYPES_PROPERTYNAME = \OCA\DAV\Connector\Sabre\SharesPlugin::SHARETYPES_PROPERTYNAME;
+
+ /**
+ * @var \Sabre\DAV\Server
+ */
+ private $server;
+
+ /**
+ * @var \Sabre\DAV\Tree
+ */
+ private $tree;
+
+ /**
+ * @var \OCP\Share\IManager
+ */
+ private $shareManager;
+
+ /**
+ * @var \OCP\Files\Folder
+ */
+ private $userFolder;
+
+ /**
+ * @var \OCA\DAV\Connector\Sabre\SharesPlugin
+ */
+ private $plugin;
+
+ public function setUp() {
+ parent::setUp();
+ $this->server = new \Sabre\DAV\Server();
+ $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->shareManager = $this->getMock('\OCP\Share\IManager');
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->once())
+ ->method('getUID')
+ ->will($this->returnValue('user1'));
+ $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession->expects($this->once())
+ ->method('getUser')
+ ->will($this->returnValue($user));
+
+ $this->userFolder = $this->getMock('\OCP\Files\Folder');
+
+ $this->plugin = new \OCA\DAV\Connector\Sabre\SharesPlugin(
+ $this->tree,
+ $userSession,
+ $this->userFolder,
+ $this->shareManager
+ );
+ $this->plugin->initialize($this->server);
+ }
+
+ /**
+ * @dataProvider sharesGetPropertiesDataProvider
+ */
+ public function testGetProperties($shareTypes) {
+ $sabreNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $sabreNode->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(123));
+ $sabreNode->expects($this->once())
+ ->method('getPath')
+ ->will($this->returnValue('/subdir'));
+
+ // node API nodes
+ $node = $this->getMock('\OCP\Files\Folder');
+
+ $this->userFolder->expects($this->once())
+ ->method('get')
+ ->with('/subdir')
+ ->will($this->returnValue($node));
+
+ $this->shareManager->expects($this->any())
+ ->method('getSharesBy')
+ ->with(
+ $this->equalTo('user1'),
+ $this->anything(),
+ $this->anything(),
+ $this->equalTo(false),
+ $this->equalTo(1)
+ )
+ ->will($this->returnCallback(function($userId, $requestedShareType, $node, $flag, $limit) use ($shareTypes){
+ if (in_array($requestedShareType, $shareTypes)) {
+ return ['dummyshare'];
+ }
+ return [];
+ }));
+
+ $propFind = new \Sabre\DAV\PropFind(
+ '/dummyPath',
+ [self::SHARETYPES_PROPERTYNAME],
+ 0
+ );
+
+ $this->plugin->handleGetProperties(
+ $propFind,
+ $sabreNode
+ );
+
+ $result = $propFind->getResultForMultiStatus();
+
+ $this->assertEmpty($result[404]);
+ unset($result[404]);
+ $this->assertEquals($shareTypes, $result[200][self::SHARETYPES_PROPERTYNAME]->getShareTypes());
+ }
+
+ /**
+ * @dataProvider sharesGetPropertiesDataProvider
+ */
+ public function testPreloadThenGetProperties($shareTypes) {
+ $sabreNode1 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $sabreNode1->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(111));
+ $sabreNode1->expects($this->never())
+ ->method('getPath');
+ $sabreNode2 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $sabreNode2->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(222));
+ $sabreNode2->expects($this->never())
+ ->method('getPath');
+
+ $sabreNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $sabreNode->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(123));
+ // never, because we use getDirectoryListing from the Node API instead
+ $sabreNode->expects($this->never())
+ ->method('getChildren');
+ $sabreNode->expects($this->any())
+ ->method('getPath')
+ ->will($this->returnValue('/subdir'));
+
+ // node API nodes
+ $node = $this->getMock('\OCP\Files\Folder');
+ $node->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(123));
+ $node1 = $this->getMock('\OCP\Files\File');
+ $node1->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(111));
+ $node2 = $this->getMock('\OCP\Files\File');
+ $node2->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(222));
+ $node->expects($this->once())
+ ->method('getDirectoryListing')
+ ->will($this->returnValue([$node1, $node2]));
+
+ $this->userFolder->expects($this->once())
+ ->method('get')
+ ->with('/subdir')
+ ->will($this->returnValue($node));
+
+ $this->shareManager->expects($this->any())
+ ->method('getSharesBy')
+ ->with(
+ $this->equalTo('user1'),
+ $this->anything(),
+ $this->anything(),
+ $this->equalTo(false),
+ $this->equalTo(1)
+ )
+ ->will($this->returnCallback(function($userId, $requestedShareType, $node, $flag, $limit) use ($shareTypes){
+ if ($node->getId() === 111 && in_array($requestedShareType, $shareTypes)) {
+ return ['dummyshare'];
+ }
+
+ return [];
+ }));
+
+ // simulate sabre recursive PROPFIND traversal
+ $propFindRoot = new \Sabre\DAV\PropFind(
+ '/subdir',
+ [self::SHARETYPES_PROPERTYNAME],
+ 1
+ );
+ $propFind1 = new \Sabre\DAV\PropFind(
+ '/subdir/test.txt',
+ [self::SHARETYPES_PROPERTYNAME],
+ 0
+ );
+ $propFind2 = new \Sabre\DAV\PropFind(
+ '/subdir/test2.txt',
+ [self::SHARETYPES_PROPERTYNAME],
+ 0
+ );
+
+ $this->plugin->handleGetProperties(
+ $propFindRoot,
+ $sabreNode
+ );
+ $this->plugin->handleGetProperties(
+ $propFind1,
+ $sabreNode1
+ );
+ $this->plugin->handleGetProperties(
+ $propFind2,
+ $sabreNode2
+ );
+
+ $result = $propFind1->getResultForMultiStatus();
+
+ $this->assertEmpty($result[404]);
+ unset($result[404]);
+ $this->assertEquals($shareTypes, $result[200][self::SHARETYPES_PROPERTYNAME]->getShareTypes());
+ }
+
+ function sharesGetPropertiesDataProvider() {
+ return [
+ [[]],
+ [[\OCP\Share::SHARE_TYPE_USER]],
+ [[\OCP\Share::SHARE_TYPE_GROUP]],
+ [[\OCP\Share::SHARE_TYPE_LINK]],
+ [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP]],
+ [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]],
+ [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK]],
+ [[\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]],
+ ];
+ }
+}
diff --git a/apps/files/appinfo/application.php b/apps/files/appinfo/application.php
index bc6dc9fb9ed..593e0533c80 100644
--- a/apps/files/appinfo/application.php
+++ b/apps/files/appinfo/application.php
@@ -40,8 +40,10 @@ class Application extends App {
return new ApiController(
$c->query('AppName'),
$c->query('Request'),
+ $server->getUserSession(),
$c->query('TagService'),
- $server->getPreviewManager()
+ $server->getPreviewManager(),
+ $server->getShareManager()
);
});
diff --git a/apps/files/controller/apicontroller.php b/apps/files/controller/apicontroller.php
index c96d92a046b..43abf2ff458 100644
--- a/apps/files/controller/apicontroller.php
+++ b/apps/files/controller/apicontroller.php
@@ -34,6 +34,10 @@ use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCA\Files\Service\TagService;
use OCP\IPreview;
+use OCP\Share\IManager;
+use OCP\Files\FileInfo;
+use OCP\Files\Node;
+use OCP\IUserSession;
/**
* Class ApiController
@@ -43,8 +47,12 @@ use OCP\IPreview;
class ApiController extends Controller {
/** @var TagService */
private $tagService;
+ /** @var IManager **/
+ private $shareManager;
/** @var IPreview */
private $previewManager;
+ /** IUserSession */
+ private $userSession;
/**
* @param string $appName
@@ -54,11 +62,15 @@ class ApiController extends Controller {
*/
public function __construct($appName,
IRequest $request,
+ IUserSession $userSession,
TagService $tagService,
- IPreview $previewManager){
+ IPreview $previewManager,
+ IManager $shareManager) {
parent::__construct($appName, $request);
+ $this->userSession = $userSession;
$this->tagService = $tagService;
$this->previewManager = $previewManager;
+ $this->shareManager = $shareManager;
}
/**
@@ -132,8 +144,10 @@ class ApiController extends Controller {
*/
public function getFilesByTag($tagName) {
$files = array();
- $fileInfos = $this->tagService->getFilesByTag($tagName);
- foreach ($fileInfos as &$fileInfo) {
+ $nodes = $this->tagService->getFilesByTag($tagName);
+ foreach ($nodes as &$node) {
+ $shareTypes = $this->getShareTypes($node);
+ $fileInfo = $node->getFileInfo();
$file = \OCA\Files\Helper::formatFileInfo($fileInfo);
$parts = explode('/', dirname($fileInfo->getPath()), 4);
if(isset($parts[3])) {
@@ -142,9 +156,43 @@ class ApiController extends Controller {
$file['path'] = '/';
}
$file['tags'] = [$tagName];
+ if (!empty($shareTypes)) {
+ $file['shareTypes'] = $shareTypes;
+ }
$files[] = $file;
}
return new DataResponse(['files' => $files]);
}
+ /**
+ * Return a list of share types for outgoing shares
+ *
+ * @param Node $node file node
+ *
+ * @return int[] array of share types
+ */
+ private function getShareTypes(Node $node) {
+ $userId = $this->userSession->getUser()->getUID();
+ $shareTypes = [];
+ $requestedShareTypes = [
+ \OCP\Share::SHARE_TYPE_USER,
+ \OCP\Share::SHARE_TYPE_GROUP,
+ \OCP\Share::SHARE_TYPE_LINK
+ ];
+ foreach ($requestedShareTypes as $requestedShareType) {
+ // one of each type is enough to find out about the types
+ $shares = $this->shareManager->getSharesBy(
+ $userId,
+ $requestedShareType,
+ $node,
+ false,
+ 1
+ );
+ if (!empty($shares)) {
+ $shareTypes[] = $requestedShareType;
+ }
+ }
+ return $shareTypes;
+ }
+
}
diff --git a/apps/files/service/tagservice.php b/apps/files/service/tagservice.php
index e1425c46615..57cad43a539 100644
--- a/apps/files/service/tagservice.php
+++ b/apps/files/service/tagservice.php
@@ -25,6 +25,7 @@
namespace OCA\Files\Service;
use OC\Files\FileInfo;
+use OCP\Files\Node;
/**
* Service class to manage tags on files.
@@ -93,7 +94,7 @@ class TagService {
* Get all files for the given tag
*
* @param string $tagName tag name to filter by
- * @return FileInfo[] list of matching files
+ * @return Node[] list of matching files
* @throws \Exception if the tag does not exist
*/
public function getFilesByTag($tagName) {
@@ -103,15 +104,11 @@ class TagService {
return [];
}
- $fileInfos = [];
+ $allNodes = [];
foreach ($fileIds as $fileId) {
- $nodes = $this->homeFolder->getById((int) $fileId);
- foreach ($nodes as $node) {
- /** @var \OC\Files\Node\Node $node */
- $fileInfos[] = $node->getFileInfo();
- }
+ $allNodes = array_merge($allNodes, $this->homeFolder->getById((int) $fileId));
}
- return $fileInfos;
+ return $allNodes;
}
}
diff --git a/apps/files/tests/controller/apicontrollertest.php b/apps/files/tests/controller/apicontrollertest.php
index 6fb8340ead8..a9b248a36fe 100644
--- a/apps/files/tests/controller/apicontrollertest.php
+++ b/apps/files/tests/controller/apicontrollertest.php
@@ -51,14 +51,27 @@ class ApiControllerTest extends TestCase {
private $preview;
/** @var ApiController */
private $apiController;
+ /** @var \OCP\Share\IManager */
+ private $shareManager;
public function setUp() {
$this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('user1'));
+ $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession->expects($this->any())
+ ->method('getUser')
+ ->will($this->returnValue($user));
$this->tagService = $this->getMockBuilder('\OCA\Files\Service\TagService')
->disableOriginalConstructor()
->getMock();
+ $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->preview = $this->getMockBuilder('\OCP\IPreview')
->disableOriginalConstructor()
->getMock();
@@ -66,8 +79,10 @@ class ApiControllerTest extends TestCase {
$this->apiController = new ApiController(
$this->appName,
$this->request,
+ $userSession,
$this->tagService,
- $this->preview
+ $this->preview,
+ $this->shareManager
);
}
@@ -101,10 +116,32 @@ class ApiControllerTest extends TestCase {
->disableOriginalConstructor()
->getMock()
);
+ $node = $this->getMockBuilder('\OC\Files\Node\File')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $node->expects($this->once())
+ ->method('getFileInfo')
+ ->will($this->returnValue($fileInfo));
$this->tagService->expects($this->once())
->method('getFilesByTag')
->with($this->equalTo([$tagName]))
- ->will($this->returnValue([$fileInfo]));
+ ->will($this->returnValue([$node]));
+
+ $this->shareManager->expects($this->any())
+ ->method('getSharesBy')
+ ->with(
+ $this->equalTo('user1'),
+ $this->anything(),
+ $node,
+ $this->equalTo(false),
+ $this->equalTo(1)
+ )
+ ->will($this->returnCallback(function($userId, $shareType) {
+ if ($shareType === \OCP\Share::SHARE_TYPE_USER || $shareType === \OCP\Share::SHARE_TYPE_LINK) {
+ return ['dummy_share'];
+ }
+ return [];
+ }));
$expected = new DataResponse([
'files' => [
@@ -124,6 +161,7 @@ class ApiControllerTest extends TestCase {
'MyTagName'
]
],
+ 'shareTypes' => [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK]
],
],
]);
@@ -166,10 +204,22 @@ class ApiControllerTest extends TestCase {
->disableOriginalConstructor()
->getMock()
);
+ $node1 = $this->getMockBuilder('\OC\Files\Node\File')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $node1->expects($this->once())
+ ->method('getFileInfo')
+ ->will($this->returnValue($fileInfo1));
+ $node2 = $this->getMockBuilder('\OC\Files\Node\File')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $node2->expects($this->once())
+ ->method('getFileInfo')
+ ->will($this->returnValue($fileInfo2));
$this->tagService->expects($this->once())
->method('getFilesByTag')
->with($this->equalTo([$tagName]))
- ->will($this->returnValue([$fileInfo1, $fileInfo2]));
+ ->will($this->returnValue([$node1, $node2]));
$expected = new DataResponse([
'files' => [
diff --git a/apps/files_external/3rdparty/.gitignore b/apps/files_external/3rdparty/.gitignore
index c8d4e6eed0b..b56af237c35 100644
--- a/apps/files_external/3rdparty/.gitignore
+++ b/apps/files_external/3rdparty/.gitignore
@@ -2,3 +2,4 @@ example.php
icewind/smb/tests
icewind/smb/install_libsmbclient.sh
icewind/smb/.travis.yml
+icewind/streams/tests
diff --git a/apps/files_external/3rdparty/composer.json b/apps/files_external/3rdparty/composer.json
index 4c130404add..b0267ba3438 100644
--- a/apps/files_external/3rdparty/composer.json
+++ b/apps/files_external/3rdparty/composer.json
@@ -8,8 +8,8 @@
"classmap-authoritative": true
},
"require": {
- "icewind/smb": "1.0.5",
- "icewind/streams": "0.2"
+ "icewind/smb": "1.0.8",
+ "icewind/streams": "0.4"
}
}
diff --git a/apps/files_external/3rdparty/composer.lock b/apps/files_external/3rdparty/composer.lock
index 7bfb48a2c0d..13931ad757d 100644
--- a/apps/files_external/3rdparty/composer.lock
+++ b/apps/files_external/3rdparty/composer.lock
@@ -4,25 +4,25 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "669663944c7232473a1c51a6d160319d",
- "content-hash": "7612ced4391f6287fb3e50534500d217",
+ "hash": "1671a5ec7bef407432d42775f898dc34",
+ "content-hash": "9d995f0d55bee8a3b344a3c685e7b4a4",
"packages": [
{
"name": "icewind/smb",
- "version": "v1.0.5",
+ "version": "v1.0.8",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
- "reference": "acb94a0a85290d653cd64c883175b855ada5022f"
+ "reference": "764f3fc793a904eb937d619ad097fb076ff199cd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/SMB/zipball/acb94a0a85290d653cd64c883175b855ada5022f",
- "reference": "acb94a0a85290d653cd64c883175b855ada5022f",
+ "url": "https://api.github.com/repos/icewind1991/SMB/zipball/764f3fc793a904eb937d619ad097fb076ff199cd",
+ "reference": "764f3fc793a904eb937d619ad097fb076ff199cd",
"shasum": ""
},
"require": {
- "icewind/streams": "0.2.*",
+ "icewind/streams": ">=0.2.0",
"php": ">=5.3"
},
"require-dev": {
@@ -47,27 +47,28 @@
}
],
"description": "php wrapper for smbclient and libsmbclient-php",
- "time": "2016-01-20 13:12:36"
+ "time": "2016-03-17 13:29:58"
},
{
"name": "icewind/streams",
- "version": "0.2",
+ "version": "0.4.0",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/Streams.git",
- "reference": "5aae45f2ddd3d1a6e2a496dd5d1e7857bfeb605a"
+ "reference": "9ca40274645a967ecc3408b0ca2e6255ead1d1d3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/Streams/zipball/5aae45f2ddd3d1a6e2a496dd5d1e7857bfeb605a",
- "reference": "5aae45f2ddd3d1a6e2a496dd5d1e7857bfeb605a",
+ "url": "https://api.github.com/repos/icewind1991/Streams/zipball/9ca40274645a967ecc3408b0ca2e6255ead1d1d3",
+ "reference": "9ca40274645a967ecc3408b0ca2e6255ead1d1d3",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
- "satooshi/php-coveralls": "dev-master"
+ "phpunit/phpunit": "^4.8",
+ "satooshi/php-coveralls": "v1.0.0"
},
"type": "library",
"autoload": {
@@ -87,7 +88,7 @@
}
],
"description": "A set of generic stream wrappers",
- "time": "2014-07-30 23:46:15"
+ "time": "2016-03-17 12:32:25"
}
],
"packages-dev": [],
diff --git a/apps/files_external/3rdparty/composer/ClassLoader.php b/apps/files_external/3rdparty/composer/ClassLoader.php
index 5e1469e8307..ff6ecfb822f 100644
--- a/apps/files_external/3rdparty/composer/ClassLoader.php
+++ b/apps/files_external/3rdparty/composer/ClassLoader.php
@@ -13,9 +13,7 @@
namespace Composer\Autoload;
/**
- * ClassLoader implements a PSR-0 class loader
- *
- * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
@@ -39,6 +37,8 @@ namespace Composer\Autoload;
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
+ * @see http://www.php-fig.org/psr/psr-0/
+ * @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
@@ -147,7 +147,7 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
- * @param array|string $paths The PSR-0 base directories
+ * @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
diff --git a/apps/files_external/3rdparty/composer/autoload_classmap.php b/apps/files_external/3rdparty/composer/autoload_classmap.php
index 5b0f2511e12..942dbce7336 100644
--- a/apps/files_external/3rdparty/composer/autoload_classmap.php
+++ b/apps/files_external/3rdparty/composer/autoload_classmap.php
@@ -52,12 +52,23 @@ return array(
'Icewind\\SMB\\TimeZoneProvider' => $vendorDir . '/icewind/smb/src/TimeZoneProvider.php',
'Icewind\\Streams\\CallbackWrapper' => $vendorDir . '/icewind/streams/src/CallbackWrapper.php',
'Icewind\\Streams\\Directory' => $vendorDir . '/icewind/streams/src/Directory.php',
+ 'Icewind\\Streams\\DirectoryFilter' => $vendorDir . '/icewind/streams/src/DirectoryFilter.php',
+ 'Icewind\\Streams\\DirectoryWrapper' => $vendorDir . '/icewind/streams/src/DirectoryWrapper.php',
'Icewind\\Streams\\File' => $vendorDir . '/icewind/streams/src/File.php',
'Icewind\\Streams\\IteratorDirectory' => $vendorDir . '/icewind/streams/src/IteratorDirectory.php',
'Icewind\\Streams\\NullWrapper' => $vendorDir . '/icewind/streams/src/NullWrapper.php',
- 'Icewind\\Streams\\Tests\\CallbackWrapper' => $vendorDir . '/icewind/streams/tests/CallbackWrapper.php',
- 'Icewind\\Streams\\Tests\\IteratorDirectory' => $vendorDir . '/icewind/streams/tests/IteratorDirectory.php',
- 'Icewind\\Streams\\Tests\\NullWrapper' => $vendorDir . '/icewind/streams/tests/NullWrapper.php',
- 'Icewind\\Streams\\Tests\\Wrapper' => $vendorDir . '/icewind/streams/tests/Wrapper.php',
+ 'Icewind\\Streams\\Path' => $vendorDir . '/icewind/streams/src/Path.php',
+ 'Icewind\\Streams\\RetryWrapper' => $vendorDir . '/icewind/streams/src/RetryWrapper.php',
+ 'Icewind\\Streams\\SeekableWrapper' => $vendorDir . '/icewind/streams/src/SeekableWrapper.php',
+ 'Icewind\\Streams\\Tests\\DirectoryFilter' => $vendorDir . '/icewind/streams/tests/DirectoryFilter.php',
+ 'Icewind\\Streams\\Tests\\DirectoryWrapper' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php',
+ 'Icewind\\Streams\\Tests\\DirectoryWrapperDummy' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php',
+ 'Icewind\\Streams\\Tests\\DirectoryWrapperNull' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php',
+ 'Icewind\\Streams\\Tests\\PartialWrapper' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php',
+ 'Icewind\\Streams\\Tests\\RetryWrapper' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php',
+ 'Icewind\\Streams\\Tests\\SeekableWrapper' => $vendorDir . '/icewind/streams/tests/SeekableWrapper.php',
+ 'Icewind\\Streams\\Tests\\UrlCallBack' => $vendorDir . '/icewind/streams/tests/UrlCallBack.php',
+ 'Icewind\\Streams\\Url' => $vendorDir . '/icewind/streams/src/Url.php',
+ 'Icewind\\Streams\\UrlCallback' => $vendorDir . '/icewind/streams/src/UrlCallBack.php',
'Icewind\\Streams\\Wrapper' => $vendorDir . '/icewind/streams/src/Wrapper.php',
);
diff --git a/apps/files_external/3rdparty/composer/autoload_real.php b/apps/files_external/3rdparty/composer/autoload_real.php
index 9e8b3b558e5..6f27fffb9da 100644
--- a/apps/files_external/3rdparty/composer/autoload_real.php
+++ b/apps/files_external/3rdparty/composer/autoload_real.php
@@ -23,16 +23,6 @@ class ComposerAutoloaderInit98fe9b281934250b3a93f69a5ce843b3
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit98fe9b281934250b3a93f69a5ce843b3', 'loadClassLoader'));
- $map = require __DIR__ . '/autoload_namespaces.php';
- foreach ($map as $namespace => $path) {
- $loader->set($namespace, $path);
- }
-
- $map = require __DIR__ . '/autoload_psr4.php';
- foreach ($map as $namespace => $path) {
- $loader->setPsr4($namespace, $path);
- }
-
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
@@ -44,8 +34,3 @@ class ComposerAutoloaderInit98fe9b281934250b3a93f69a5ce843b3
return $loader;
}
}
-
-function composerRequire98fe9b281934250b3a93f69a5ce843b3($file)
-{
- require $file;
-}
diff --git a/apps/files_external/3rdparty/composer/installed.json b/apps/files_external/3rdparty/composer/installed.json
index 6e0b5d0d8f9..48f8c555c34 100644
--- a/apps/files_external/3rdparty/composer/installed.json
+++ b/apps/files_external/3rdparty/composer/installed.json
@@ -1,26 +1,27 @@
[
{
"name": "icewind/streams",
- "version": "0.2",
- "version_normalized": "0.2.0.0",
+ "version": "0.4.0",
+ "version_normalized": "0.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/Streams.git",
- "reference": "5aae45f2ddd3d1a6e2a496dd5d1e7857bfeb605a"
+ "reference": "9ca40274645a967ecc3408b0ca2e6255ead1d1d3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/Streams/zipball/5aae45f2ddd3d1a6e2a496dd5d1e7857bfeb605a",
- "reference": "5aae45f2ddd3d1a6e2a496dd5d1e7857bfeb605a",
+ "url": "https://api.github.com/repos/icewind1991/Streams/zipball/9ca40274645a967ecc3408b0ca2e6255ead1d1d3",
+ "reference": "9ca40274645a967ecc3408b0ca2e6255ead1d1d3",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
- "satooshi/php-coveralls": "dev-master"
+ "phpunit/phpunit": "^4.8",
+ "satooshi/php-coveralls": "v1.0.0"
},
- "time": "2014-07-30 23:46:15",
+ "time": "2016-03-17 12:32:25",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -43,28 +44,28 @@
},
{
"name": "icewind/smb",
- "version": "v1.0.5",
- "version_normalized": "1.0.5.0",
+ "version": "v1.0.8",
+ "version_normalized": "1.0.8.0",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
- "reference": "acb94a0a85290d653cd64c883175b855ada5022f"
+ "reference": "764f3fc793a904eb937d619ad097fb076ff199cd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/SMB/zipball/acb94a0a85290d653cd64c883175b855ada5022f",
- "reference": "acb94a0a85290d653cd64c883175b855ada5022f",
+ "url": "https://api.github.com/repos/icewind1991/SMB/zipball/764f3fc793a904eb937d619ad097fb076ff199cd",
+ "reference": "764f3fc793a904eb937d619ad097fb076ff199cd",
"shasum": ""
},
"require": {
- "icewind/streams": "0.2.*",
+ "icewind/streams": ">=0.2.0",
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"satooshi/php-coveralls": "v1.0.0"
},
- "time": "2016-01-20 13:12:36",
+ "time": "2016-03-17 13:29:58",
"type": "library",
"installation-source": "source",
"autoload": {
diff --git a/apps/files_external/3rdparty/icewind/smb/README.md b/apps/files_external/3rdparty/icewind/smb/README.md
index a0864717b09..32f3c650f87 100644
--- a/apps/files_external/3rdparty/icewind/smb/README.md
+++ b/apps/files_external/3rdparty/icewind/smb/README.md
@@ -75,7 +75,7 @@ $share = $server->getShare('test');
$content = $share->dir('test');
foreach ($content as $info) {
- echo $name->getName() . "\n";
+ echo $info->getName() . "\n";
echo "\tsize :" . $info->getSize() . "\n";
}
```
diff --git a/apps/files_external/3rdparty/icewind/smb/composer.json b/apps/files_external/3rdparty/icewind/smb/composer.json
index 2e1fd35f7a6..4ac8b27e725 100644
--- a/apps/files_external/3rdparty/icewind/smb/composer.json
+++ b/apps/files_external/3rdparty/icewind/smb/composer.json
@@ -10,7 +10,7 @@
],
"require" : {
"php": ">=5.3",
- "icewind/streams": "0.2.*"
+ "icewind/streams": ">=0.2.0"
},
"require-dev": {
"satooshi/php-coveralls" : "v1.0.0",
diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php
index 0b184fd585c..27d975514a3 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php
@@ -239,8 +239,9 @@ class NativeShare extends AbstractShare {
*/
public function read($source) {
$this->connect();
- $handle = $this->state->open($this->buildUrl($source), 'r');
- return NativeStream::wrap($this->state, $handle, 'r');
+ $url = $this->buildUrl($source);
+ $handle = $this->state->open($url, 'r');
+ return NativeStream::wrap($this->state, $handle, 'r', $url);
}
/**
@@ -254,8 +255,9 @@ class NativeShare extends AbstractShare {
*/
public function write($source) {
$this->connect();
- $handle = $this->state->create($this->buildUrl($source));
- return NativeStream::wrap($this->state, $handle, 'w');
+ $url = $this->buildUrl($source);
+ $handle = $this->state->create($url);
+ return NativeStream::wrap($this->state, $handle, 'w', $url);
}
/**
diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php b/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php
index 07bd2f1e797..481395b025a 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php
@@ -7,6 +7,7 @@
namespace Icewind\SMB;
+use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\InvalidRequestException;
use Icewind\Streams\File;
@@ -32,19 +33,26 @@ class NativeStream implements File {
private $eof = false;
/**
+ * @var string
+ */
+ private $url;
+
+ /**
* Wrap a stream from libsmbclient-php into a regular php stream
*
* @param \Icewind\SMB\NativeState $state
* @param resource $smbStream
* @param string $mode
+ * @param string $url
* @return resource
*/
- public static function wrap($state, $smbStream, $mode) {
+ public static function wrap($state, $smbStream, $mode, $url) {
stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeStream');
$context = stream_context_create(array(
'nativesmb' => array(
'state' => $state,
- 'handle' => $smbStream
+ 'handle' => $smbStream,
+ 'url' => $url
)
));
$fh = fopen('nativesmb://', $mode, false, $context);
@@ -68,6 +76,7 @@ class NativeStream implements File {
$context = stream_context_get_options($this->context);
$this->state = $context['nativesmb']['state'];
$this->handle = $context['nativesmb']['handle'];
+ $this->url = $context['nativesmb']['url'];
return true;
}
@@ -89,7 +98,11 @@ class NativeStream implements File {
}
public function stream_stat() {
- return $this->state->fstat($this->handle);
+ try {
+ return $this->state->stat($this->url);
+ } catch (Exception $e) {
+ return false;
+ }
}
public function stream_tell() {
diff --git a/apps/files_external/3rdparty/icewind/streams-dummy/composer.json b/apps/files_external/3rdparty/icewind/streams-dummy/composer.json
new file mode 100644
index 00000000000..ad6a6a1b1c1
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams-dummy/composer.json
@@ -0,0 +1,7 @@
+{
+ "name": "icewind/streams-dummy",
+ "provide": {
+ "icewind/streams": "0.2"
+ }
+}
+
diff --git a/apps/files_external/3rdparty/icewind/streams/.travis.yml b/apps/files_external/3rdparty/icewind/streams/.travis.yml
index dfa52767dda..d2e1afaad67 100644
--- a/apps/files_external/3rdparty/icewind/streams/.travis.yml
+++ b/apps/files_external/3rdparty/icewind/streams/.travis.yml
@@ -1,13 +1,14 @@
language: php
php:
- - 5.3
- 5.4
- 5.5
+ - 5.6
+ - 7.0
- hhvm
matrix:
- allow_failures:
- - php: hhvm # due to facebook/hhvm#3321
+ allow_failures:
+ - php: hhvm # due to facebook/hhvm#3321
env:
global:
diff --git a/apps/files_external/3rdparty/icewind/streams/LICENCE b/apps/files_external/3rdparty/icewind/streams/LICENCE
new file mode 100644
index 00000000000..a194b9117b8
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/LICENCE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Robin Appelman
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/apps/files_external/3rdparty/icewind/streams/README.md b/apps/files_external/3rdparty/icewind/streams/README.md
index 54f6d19a560..ca13db28e44 100644
--- a/apps/files_external/3rdparty/icewind/streams/README.md
+++ b/apps/files_external/3rdparty/icewind/streams/README.md
@@ -2,6 +2,7 @@
[![Build Status](https://travis-ci.org/icewind1991/Streams.svg?branch=master)](https://travis-ci.org/icewind1991/Streams)
[![Coverage Status](https://img.shields.io/coveralls/icewind1991/Streams.svg)](https://coveralls.io/r/icewind1991/Streams?branch=master)
+[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/icewind1991/Streams/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/icewind1991/Streams/?branch=master)
Generic stream wrappers for php.
diff --git a/apps/files_external/3rdparty/icewind/streams/composer.json b/apps/files_external/3rdparty/icewind/streams/composer.json
index 86d3c834258..f2f3e0fc255 100644
--- a/apps/files_external/3rdparty/icewind/streams/composer.json
+++ b/apps/files_external/3rdparty/icewind/streams/composer.json
@@ -12,7 +12,8 @@
"php": ">=5.3"
},
"require-dev" : {
- "satooshi/php-coveralls": "dev-master"
+ "satooshi/php-coveralls": "v1.0.0",
+ "phpunit/phpunit": "^4.8"
},
"autoload" : {
"psr-4": {
diff --git a/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php b/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php
index fd99aa6ebe8..c5847b95fdb 100644
--- a/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php
+++ b/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php
@@ -13,10 +13,11 @@ namespace Icewind\Streams;
* The following options should be passed in the context when opening the stream
* [
* 'callback' => [
- * 'source' => resource
- * 'read' => function($count){} (optional)
- * 'write' => function($data){} (optional)
- * 'close' => function(){} (optional)
+ * 'source' => resource
+ * 'read' => function($count){} (optional)
+ * 'write' => function($data){} (optional)
+ * 'close' => function(){} (optional)
+ * 'readdir' => function(){} (optional)
* ]
* ]
*
@@ -39,54 +40,56 @@ class CallbackWrapper extends Wrapper {
protected $closeCallback;
/**
+ * @var callable
+ */
+ protected $readDirCallBack;
+
+ /**
* Wraps a stream with the provided callbacks
*
* @param resource $source
* @param callable $read (optional)
* @param callable $write (optional)
* @param callable $close (optional)
+ * @param callable $readDir (optional)
* @return resource
*
* @throws \BadMethodCallException
*/
- public static function wrap($source, $read = null, $write = null, $close = null) {
+ public static function wrap($source, $read = null, $write = null, $close = null, $readDir = null) {
$context = stream_context_create(array(
'callback' => array(
'source' => $source,
'read' => $read,
'write' => $write,
- 'close' => $close
+ 'close' => $close,
+ 'readDir' => $readDir
)
));
- stream_wrapper_register('callback', '\Icewind\Streams\CallbackWrapper');
- try {
- $wrapped = fopen('callback://', 'r+', false, $context);
- } catch (\BadMethodCallException $e) {
- stream_wrapper_unregister('callback');
- throw $e;
- }
- stream_wrapper_unregister('callback');
- return $wrapped;
+ return Wrapper::wrapSource($source, $context, 'callback', '\Icewind\Streams\CallbackWrapper');
}
- public function stream_open($path, $mode, $options, &$opened_path) {
+ protected function open() {
$context = $this->loadContext('callback');
- if (isset($context['read']) and is_callable($context['read'])) {
- $this->readCallback = $context['read'];
- }
- if (isset($context['write']) and is_callable($context['write'])) {
- $this->writeCallback = $context['write'];
- }
- if (isset($context['close']) and is_callable($context['close'])) {
- $this->closeCallback = $context['close'];
- }
+ $this->readCallback = $context['read'];
+ $this->writeCallback = $context['write'];
+ $this->closeCallback = $context['close'];
+ $this->readDirCallBack = $context['readDir'];
return true;
}
+ public function dir_opendir($path, $options) {
+ return $this->open();
+ }
+
+ public function stream_open($path, $mode, $options, &$opened_path) {
+ return $this->open();
+ }
+
public function stream_read($count) {
$result = parent::stream_read($count);
- if ($this->readCallback) {
+ if (is_callable($this->readCallback)) {
call_user_func($this->readCallback, $count);
}
return $result;
@@ -94,7 +97,7 @@ class CallbackWrapper extends Wrapper {
public function stream_write($data) {
$result = parent::stream_write($data);
- if ($this->writeCallback) {
+ if (is_callable($this->writeCallback)) {
call_user_func($this->writeCallback, $data);
}
return $result;
@@ -102,9 +105,17 @@ class CallbackWrapper extends Wrapper {
public function stream_close() {
$result = parent::stream_close();
- if ($this->closeCallback) {
+ if (is_callable($this->closeCallback)) {
call_user_func($this->closeCallback);
}
return $result;
}
+
+ public function dir_readdir() {
+ $result = parent::dir_readdir();
+ if (is_callable($this->readDirCallBack)) {
+ call_user_func($this->readDirCallBack);
+ }
+ return $result;
+ }
}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/DirectoryFilter.php b/apps/files_external/3rdparty/icewind/streams/src/DirectoryFilter.php
new file mode 100644
index 00000000000..4b869699000
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/src/DirectoryFilter.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\Streams;
+
+/**
+ * Wrapper allows filtering of directories
+ *
+ * The filter callback will be called for each entry in the folder
+ * when the callback return false the entry will be filtered out
+ */
+class DirectoryFilter extends DirectoryWrapper {
+ /**
+ * @var callable
+ */
+ private $filter;
+
+ /**
+ * @param string $path
+ * @param array $options
+ * @return bool
+ */
+ public function dir_opendir($path, $options) {
+ $context = $this->loadContext('filter');
+ $this->filter = $context['filter'];
+ return true;
+ }
+
+ /**
+ * @return string
+ */
+ public function dir_readdir() {
+ $file = readdir($this->source);
+ $filter = $this->filter;
+ // keep reading untill we have an accepted entry or we're at the end of the folder
+ while ($file !== false && $filter($file) === false) {
+ $file = readdir($this->source);
+ }
+ return $file;
+ }
+
+ /**
+ * @param resource $source
+ * @param callable $filter
+ * @return resource
+ */
+ public static function wrap($source, callable $filter) {
+ $options = array(
+ 'filter' => array(
+ 'source' => $source,
+ 'filter' => $filter
+ )
+ );
+ return self::wrapWithOptions($options, '\Icewind\Streams\DirectoryFilter');
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/DirectoryWrapper.php b/apps/files_external/3rdparty/icewind/streams/src/DirectoryWrapper.php
new file mode 100644
index 00000000000..63e4805a807
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/src/DirectoryWrapper.php
@@ -0,0 +1,88 @@
+<?php
+/**
+ * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\Streams;
+
+class DirectoryWrapper implements Directory {
+ /**
+ * @var resource
+ */
+ public $context;
+
+ /**
+ * @var resource
+ */
+ protected $source;
+
+ /**
+ * Load the source from the stream context and return the context options
+ *
+ * @param string $name
+ * @return array
+ * @throws \Exception
+ */
+ protected function loadContext($name) {
+ $context = stream_context_get_options($this->context);
+ if (isset($context[$name])) {
+ $context = $context[$name];
+ } else {
+ throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
+ }
+ if (isset($context['source']) and is_resource($context['source'])) {
+ $this->source = $context['source'];
+ } else {
+ throw new \BadMethodCallException('Invalid context, source not set');
+ }
+ return $context;
+ }
+
+ /**
+ * @param string $path
+ * @param array $options
+ * @return bool
+ */
+ public function dir_opendir($path, $options) {
+ $this->loadContext('dir');
+ return true;
+ }
+
+ /**
+ * @return string
+ */
+ public function dir_readdir() {
+ return readdir($this->source);
+ }
+
+ /**
+ * @return bool
+ */
+ public function dir_closedir() {
+ closedir($this->source);
+ return true;
+ }
+
+ /**
+ * @return bool
+ */
+ public function dir_rewinddir() {
+ rewinddir($this->source);
+ return true;
+ }
+
+ /**
+ * @param array $options the options for the context to wrap the stream with
+ * @param string $class
+ * @return resource
+ */
+ protected static function wrapWithOptions($options, $class) {
+ $context = stream_context_create($options);
+ stream_wrapper_register('dirwrapper', $class);
+ $wrapped = opendir('dirwrapper://', $context);
+ stream_wrapper_unregister('dirwrapper');
+ return $wrapped;
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/File.php b/apps/files_external/3rdparty/icewind/streams/src/File.php
index 6202ef4a4b4..252b7b8971f 100644
--- a/apps/files_external/3rdparty/icewind/streams/src/File.php
+++ b/apps/files_external/3rdparty/icewind/streams/src/File.php
@@ -21,7 +21,7 @@ interface File {
public function stream_open($path, $mode, $options, &$opened_path);
/**
- * @param string $offset
+ * @param int $offset
* @param int $whence
* @return bool
*/
diff --git a/apps/files_external/3rdparty/icewind/streams/src/IteratorDirectory.php b/apps/files_external/3rdparty/icewind/streams/src/IteratorDirectory.php
index c4eac5d4ed3..6dfa42a8b68 100644
--- a/apps/files_external/3rdparty/icewind/streams/src/IteratorDirectory.php
+++ b/apps/files_external/3rdparty/icewind/streams/src/IteratorDirectory.php
@@ -45,9 +45,9 @@ class IteratorDirectory implements Directory {
} else {
throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
}
- if (isset($context['iterator']) and $context['iterator'] instanceof \Iterator) {
+ if (isset($context['iterator'])) {
$this->iterator = $context['iterator'];
- } else if (isset($context['array']) and is_array($context['array'])) {
+ } else if (isset($context['array'])) {
$this->iterator = new \ArrayIterator($context['array']);
} else {
throw new \BadMethodCallException('Invalid context, iterator or array not set');
diff --git a/apps/files_external/3rdparty/icewind/streams/src/NullWrapper.php b/apps/files_external/3rdparty/icewind/streams/src/NullWrapper.php
index 8cbaaa756d3..b6c71d98fc4 100644
--- a/apps/files_external/3rdparty/icewind/streams/src/NullWrapper.php
+++ b/apps/files_external/3rdparty/icewind/streams/src/NullWrapper.php
@@ -24,19 +24,16 @@ class NullWrapper extends Wrapper {
'null' => array(
'source' => $source)
));
- stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
- try {
- $wrapped = fopen('null://', 'r+', false, $context);
- } catch (\BadMethodCallException $e) {
- stream_wrapper_unregister('null');
- throw $e;
- }
- stream_wrapper_unregister('null');
- return $wrapped;
+ return Wrapper::wrapSource($source, $context, 'null', '\Icewind\Streams\NullWrapper');
}
public function stream_open($path, $mode, $options, &$opened_path) {
$this->loadContext('null');
return true;
}
+
+ public function dir_opendir($path, $options) {
+ $this->loadContext('null');
+ return true;
+ }
}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/Path.php b/apps/files_external/3rdparty/icewind/streams/src/Path.php
new file mode 100644
index 00000000000..46d2156b69a
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/src/Path.php
@@ -0,0 +1,104 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\Streams;
+
+/**
+ * A string-like object that automatically registers a stream wrapper when used and removes the stream wrapper when no longer used
+ *
+ * Can optionally pass context options to the stream wrapper
+ */
+class Path {
+
+ /**
+ * @var bool
+ */
+ protected $registered = false;
+
+ /**
+ * @var string
+ */
+ protected $protocol;
+
+ /**
+ * @var string
+ */
+ protected $class;
+
+ /**
+ * @var array
+ */
+ protected $contextOptions;
+
+ /**
+ * @param string $class
+ * @param array $contextOptions
+ */
+ public function __construct($class, $contextOptions = array()) {
+ $this->class = $class;
+ $this->contextOptions = $contextOptions;
+ }
+
+ public function getProtocol() {
+ if (!$this->protocol) {
+ $this->protocol = 'auto' . uniqid();
+ }
+ return $this->protocol;
+ }
+
+ public function wrapPath($path) {
+ return $this->getProtocol() . '://' . $path;
+ }
+
+ protected function register() {
+ if (!$this->registered) {
+ $this->appendDefaultContent($this->getProtocol(), $this->contextOptions);
+ stream_wrapper_register($this->getProtocol(), $this->class);
+ $this->registered = true;
+ }
+ }
+
+ protected function unregister() {
+ stream_wrapper_unregister($this->getProtocol());
+ $this->unsetDefaultContent($this->getProtocol());
+ $this->registered = false;
+ }
+
+ /**
+ * Add values to the default stream context
+ *
+ * @param string $key
+ * @param array $values
+ */
+ protected function appendDefaultContent($key, $values) {
+ $context = stream_context_get_default();
+ $defaults = stream_context_get_options($context);
+ $defaults[$key] = $values;
+ stream_context_set_default($defaults);
+ }
+
+ /**
+ * Remove values from the default stream context
+ *
+ * @param string $key
+ */
+ protected function unsetDefaultContent($key) {
+ $context = stream_context_get_default();
+ $defaults = stream_context_get_options($context);
+ unset($defaults[$key]);
+ stream_context_set_default($defaults);
+ }
+
+ public function __toString() {
+ $this->register();
+ return $this->protocol . '://';
+ }
+
+ public function __destruct() {
+ $this->unregister();
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/RetryWrapper.php b/apps/files_external/3rdparty/icewind/streams/src/RetryWrapper.php
new file mode 100644
index 00000000000..84b43f6bd02
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/src/RetryWrapper.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Copyright (c) 2016 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\Streams;
+
+/**
+ * Wrapper that retries reads/writes to remote streams that dont deliver/recieve all requested data at once
+ */
+class RetryWrapper extends Wrapper {
+
+ /**
+ * Wraps a stream with the provided callbacks
+ *
+ * @param resource $source
+ * @return resource
+ */
+ public static function wrap($source) {
+ $context = stream_context_create(array(
+ 'retry' => array(
+ 'source' => $source
+ )
+ ));
+ return Wrapper::wrapSource($source, $context, 'retry', '\Icewind\Streams\RetryWrapper');
+ }
+
+ protected function open() {
+ $this->loadContext('retry');
+ return true;
+ }
+
+ public function dir_opendir($path, $options) {
+ return false;
+ }
+
+ public function stream_open($path, $mode, $options, &$opened_path) {
+ return $this->open();
+ }
+
+ public function stream_read($count) {
+ $result = parent::stream_read($count);
+
+ $bytesReceived = strlen($result);
+ while ($bytesReceived < $count && !$this->stream_eof()) {
+ $result .= parent::stream_read($count - $bytesReceived);
+ $bytesReceived = strlen($result);
+ }
+
+ return $result;
+ }
+
+ public function stream_write($data) {
+ $bytesToSend = strlen($data);
+ $result = parent::stream_write($data);
+
+ while ($result < $bytesToSend && !$this->stream_eof()) {
+ $dataLeft = substr($data, $result);
+ $result += parent::stream_write($dataLeft);
+ }
+
+ return $result;
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/SeekableWrapper.php b/apps/files_external/3rdparty/icewind/streams/src/SeekableWrapper.php
new file mode 100644
index 00000000000..d41fd73ec9c
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/src/SeekableWrapper.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\Streams;
+
+/**
+ * Wrapper that provides callbacks for write, read and close
+ *
+ * The following options should be passed in the context when opening the stream
+ * [
+ * 'callback' => [
+ * 'source' => resource
+ * ]
+ * ]
+ *
+ * All callbacks are called after the operation is executed on the source stream
+ */
+class SeekableWrapper extends Wrapper {
+ /**
+ * @var resource
+ */
+ protected $cache;
+
+ /**
+ * Wraps a stream to make it seekable
+ *
+ * @param resource $source
+ * @return resource
+ *
+ * @throws \BadMethodCallException
+ */
+ public static function wrap($source) {
+ $context = stream_context_create(array(
+ 'callback' => array(
+ 'source' => $source
+ )
+ ));
+ return Wrapper::wrapSource($source, $context, 'callback', '\Icewind\Streams\SeekableWrapper');
+ }
+
+ public function dir_opendir($path, $options) {
+ return false;
+ }
+
+ public function stream_open($path, $mode, $options, &$opened_path) {
+ $this->loadContext('callback');
+ $this->cache = fopen('php://temp', 'w+');
+ return true;
+ }
+
+ protected function readTill($position) {
+ $current = ftell($this->source);
+ if ($position > $current) {
+ $data = parent::stream_read($position - $current);
+ $cachePosition = ftell($this->cache);
+ fseek($this->cache, $current);
+ fwrite($this->cache, $data);
+ fseek($this->cache, $cachePosition);
+ }
+ }
+
+ public function stream_read($count) {
+ $current = ftell($this->cache);
+ $this->readTill($current + $count);
+ return fread($this->cache, $count);
+ }
+
+ public function stream_seek($offset, $whence = SEEK_SET) {
+ if ($whence === SEEK_SET) {
+ $target = $offset;
+ } else if ($whence === SEEK_CUR) {
+ $current = ftell($this->cache);
+ $target = $current + $offset;
+ } else {
+ return false;
+ }
+ $this->readTill($target);
+ return fseek($this->cache, $target) === 0;
+ }
+
+ public function stream_tell() {
+ return ftell($this->cache);
+ }
+
+ public function stream_eof() {
+ return parent::stream_eof() and (ftell($this->source) === ftell($this->cache));
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/Url.php b/apps/files_external/3rdparty/icewind/streams/src/Url.php
new file mode 100644
index 00000000000..d6822608a33
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/src/Url.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\Streams;
+
+/**
+ * Interface for stream wrappers that implement url functions such as unlink, stat
+ */
+interface Url {
+ /**
+ * @param string $path
+ * @param array $options
+ * @return bool
+ */
+ public function dir_opendir($path, $options);
+
+ /**
+ * @param string $path
+ * @param string $mode
+ * @param int $options
+ * @param string &$opened_path
+ * @return bool
+ */
+ public function stream_open($path, $mode, $options, &$opened_path);
+
+ /**
+ * @param string $path
+ * @param int $mode
+ * @param int $options
+ * @return bool
+ */
+ public function mkdir($path, $mode, $options);
+
+ /**
+ * @param string $source
+ * @param string $target
+ * @return bool
+ */
+ public function rename($source, $target);
+
+ /**
+ * @param string $path
+ * @param int $options
+ * @return bool
+ */
+ public function rmdir($path, $options);
+
+ /**
+ * @param string
+ * @return bool
+ */
+ public function unlink($path);
+
+ /**
+ * @param string $path
+ * @param int $flags
+ * @return array
+ */
+ public function url_stat($path, $flags);
+}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/UrlCallBack.php b/apps/files_external/3rdparty/icewind/streams/src/UrlCallBack.php
new file mode 100644
index 00000000000..580bfc6ba22
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/streams/src/UrlCallBack.php
@@ -0,0 +1,121 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\Streams;
+
+/**
+ * Wrapper that provides callbacks for url actions such as fopen, unlink, rename
+ *
+ * Usage:
+ *
+ * $path = UrlCallBack('/path/so/source', function(){
+ * echo 'fopen';
+ * }, function(){
+ * echo 'opendir';
+ * }, function(){
+ * echo 'mkdir';
+ * }, function(){
+ * echo 'rename';
+ * }, function(){
+ * echo 'rmdir';
+ * }, function(){
+ * echo 'unlink';
+ * }, function(){
+ * echo 'stat';
+ * });
+ *
+ * mkdir($path);
+ * ...
+ *
+ * All callbacks are called after the operation is executed on the source stream
+ */
+class UrlCallback extends Wrapper implements Url {
+
+ /**
+ * @param string $source
+ * @param callable $fopen
+ * @param callable $opendir
+ * @param callable $mkdir
+ * @param callable $rename
+ * @param callable $rmdir
+ * @param callable $unlink
+ * @param callable $stat
+ * @return \Icewind\Streams\Path
+ *
+ * @throws \BadMethodCallException
+ * @throws \Exception
+ */
+ public static function wrap($source, $fopen = null, $opendir = null, $mkdir = null, $rename = null, $rmdir = null,
+ $unlink = null, $stat = null) {
+ $options = array(
+ 'source' => $source,
+ 'fopen' => $fopen,
+ 'opendir' => $opendir,
+ 'mkdir' => $mkdir,
+ 'rename' => $rename,
+ 'rmdir' => $rmdir,
+ 'unlink' => $unlink,
+ 'stat' => $stat
+ );
+ return new Path('\Icewind\Streams\UrlCallBack', $options);
+ }
+
+ protected function loadContext($url) {
+ list($protocol) = explode('://', $url);
+ $options = stream_context_get_options($this->context);
+ return $options[$protocol];
+ }
+
+ protected function callCallBack($context, $callback) {
+ if (is_callable($context[$callback])) {
+ call_user_func($context[$callback]);
+ }
+ }
+
+ public function stream_open($path, $mode, $options, &$opened_path) {
+ $context = $this->loadContext($path);
+ $this->callCallBack($context, 'fopen');
+ $this->setSourceStream(fopen($context['source'], $mode));
+ return true;
+ }
+
+ public function dir_opendir($path, $options) {
+ $context = $this->loadContext($path);
+ $this->callCallBack($context, 'opendir');
+ $this->setSourceStream(opendir($context['source']));
+ return true;
+ }
+
+ public function mkdir($path, $mode, $options) {
+ $context = $this->loadContext($path);
+ $this->callCallBack($context, 'mkdir');
+ return mkdir($context['source'], $mode, $options & STREAM_MKDIR_RECURSIVE);
+ }
+
+ public function rmdir($path, $options) {
+ $context = $this->loadContext($path);
+ $this->callCallBack($context, 'rmdir');
+ return rmdir($context['source']);
+ }
+
+ public function rename($source, $target) {
+ $context = $this->loadContext($source);
+ $this->callCallBack($context, 'rename');
+ list(, $target) = explode('://', $target);
+ return rename($context['source'], $target);
+ }
+
+ public function unlink($path) {
+ $context = $this->loadContext($path);
+ $this->callCallBack($context, 'unlink');
+ return unlink($context['source']);
+ }
+
+ public function url_stat($path, $flags) {
+ throw new \Exception('stat is not supported due to php bug 50526');
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php b/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php
index 2e3a6e6cd88..53de2942ca9 100644
--- a/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php
+++ b/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php
@@ -12,7 +12,7 @@ namespace Icewind\Streams;
*
* This wrapper itself doesn't implement any functionality but is just a base class for other wrappers to extend
*/
-abstract class Wrapper implements File {
+abstract class Wrapper implements File, Directory {
/**
* @var resource
*/
@@ -25,6 +25,22 @@ abstract class Wrapper implements File {
*/
protected $source;
+ protected static function wrapSource($source, $context, $protocol, $class) {
+ try {
+ stream_wrapper_register($protocol, $class);
+ if (@rewinddir($source) === false) {
+ $wrapped = fopen($protocol . '://', 'r+', false, $context);
+ } else {
+ $wrapped = opendir($protocol . '://', $context);
+ }
+ } catch (\BadMethodCallException $e) {
+ stream_wrapper_unregister($protocol);
+ throw $e;
+ }
+ stream_wrapper_unregister($protocol);
+ return $wrapped;
+ }
+
/**
* Load the source from the stream context and return the context options
*
@@ -107,4 +123,17 @@ abstract class Wrapper implements File {
public function stream_close() {
return fclose($this->source);
}
+
+ public function dir_readdir() {
+ return readdir($this->source);
+ }
+
+ public function dir_closedir() {
+ closedir($this->source);
+ return true;
+ }
+
+ public function dir_rewinddir() {
+ return rewind($this->source);
+ }
}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php b/apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php
deleted file mode 100644
index 229b629dcd9..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-class CallbackWrapper extends Wrapper {
-
- /**
- * @param resource $source
- * @param callable $read
- * @param callable $write
- * @param callable $close
- * @return resource
- */
- protected function wrapSource($source, $read = null, $write = null, $close = null) {
- return \Icewind\Streams\CallbackWrapper::wrap($source, $read, $write, $close);
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testWrapInvalidSource() {
- $this->wrapSource('foo');
- }
-
- public function testReadCallback() {
- $called = false;
- $callBack = function () use (&$called) {
- $called = true;
- };
-
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source, $callBack);
- $this->assertEquals('foo', fread($wrapped, 3));
- $this->assertTrue($called);
- }
-
- public function testWriteCallback() {
- $lastData = '';
- $callBack = function ($data) use (&$lastData) {
- $lastData = $data;
- };
-
- $source = fopen('php://temp', 'r+');
-
- $wrapped = $this->wrapSource($source, null, $callBack);
- fwrite($wrapped, 'foobar');
- $this->assertEquals('foobar', $lastData);
- }
-
- public function testCloseCallback() {
- $called = false;
- $callBack = function () use (&$called) {
- $called = true;
- };
-
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source, null, null, $callBack);
- fclose($wrapped);
- $this->assertTrue($called);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php b/apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php
deleted file mode 100644
index 0d990468368..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-class IteratorDirectory extends \PHPUnit_Framework_TestCase {
-
- /**
- * @param \Iterator | array $source
- * @return resource
- */
- protected function wrapSource($source) {
- return \Icewind\Streams\IteratorDirectory::wrap($source);
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testNoContext() {
- $context = stream_context_create(array());
- stream_wrapper_register('iterator', '\Icewind\Streams\IteratorDirectory');
- try {
- opendir('iterator://', $context);
- stream_wrapper_unregister('iterator');
- } catch (\Exception $e) {
- stream_wrapper_unregister('iterator');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testInvalidSource() {
- $context = stream_context_create(array(
- 'dir' => array(
- 'array' => 2
- )
- ));
- stream_wrapper_register('iterator', '\Icewind\Streams\IteratorDirectory');
- try {
- opendir('iterator://', $context);
- stream_wrapper_unregister('iterator');
- } catch (\Exception $e) {
- stream_wrapper_unregister('iterator');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testWrapInvalidSource() {
- $this->wrapSource(2);
- }
-
- public function fileListProvider() {
- $longList = array_fill(0, 500, 'foo');
- return array(
- array(
- array(
- 'foo',
- 'bar',
- 'qwerty'
- )
- ),
- array(
- array(
- 'with spaces',
- 'under_scores',
- '日本語',
- 'character %$_',
- '.',
- '0',
- 'double "quotes"',
- "single 'quotes'"
- )
- ),
- array(
- array(
- 'single item'
- )
- ),
- array(
- $longList
- ),
- array(
- array()
- )
- );
- }
-
- protected function basicTest($fileList, $dh) {
- $result = array();
-
- while (($file = readdir($dh)) !== false) {
- $result[] = $file;
- }
-
- $this->assertEquals($fileList, $result);
-
- rewinddir($dh);
- if (count($fileList)) {
- $this->assertEquals($fileList[0], readdir($dh));
- } else {
- $this->assertFalse(readdir($dh));
- }
- }
-
- /**
- * @dataProvider fileListProvider
- */
- public function testBasicIterator($fileList) {
- $iterator = new \ArrayIterator($fileList);
- $dh = $this->wrapSource($iterator);
- $this->basicTest($fileList, $dh);
- }
-
- /**
- * @dataProvider fileListProvider
- */
- public function testBasicArray($fileList) {
- $dh = $this->wrapSource($fileList);
- $this->basicTest($fileList, $dh);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php b/apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php
deleted file mode 100644
index ba42b4dfea1..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-class NullWrapper extends Wrapper {
-
- /**
- * @param resource $source
- * @return resource
- */
- protected function wrapSource($source) {
- return \Icewind\Streams\NullWrapper::wrap($source);
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testNoContext() {
- stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
- $context = stream_context_create(array());
- try {
- fopen('null://', 'r+', false, $context);
- stream_wrapper_unregister('null');
- } catch (\Exception $e) {
- stream_wrapper_unregister('null');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testNoSource() {
- stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
- $context = stream_context_create(array(
- 'null' => array(
- 'source' => 'bar'
- )
- ));
- try {
- fopen('null://', 'r+', false, $context);
- } catch (\Exception $e) {
- stream_wrapper_unregister('null');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testWrapInvalidSource() {
- $this->wrapSource('foo');
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php b/apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php
deleted file mode 100644
index 6bb644dd611..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-abstract class Wrapper extends \PHPUnit_Framework_TestCase {
- /**
- * @param resource $source
- * @return resource
- */
- abstract protected function wrapSource($source);
-
- public function testRead() {
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
- $this->assertEquals('foo', fread($wrapped, 3));
- $this->assertEquals('bar', fread($wrapped, 3));
- $this->assertEquals('', fread($wrapped, 3));
- }
-
- public function testWrite() {
- $source = fopen('php://temp', 'r+');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
-
- $this->assertEquals(6, fwrite($wrapped, 'foobar'));
- rewind($source);
- $this->assertEquals('foobar', stream_get_contents($source));
- }
-
- public function testClose() {
- $source = fopen('php://temp', 'r+');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
-
- fclose($wrapped);
- $this->assertFalse(is_resource($source));
- }
-
- public function testSeekTell() {
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
-
- $this->assertEquals(0, ftell($wrapped));
-
- fseek($wrapped, 2);
- $this->assertEquals(2, ftell($source));
- $this->assertEquals(2, ftell($wrapped));
-
- fseek($wrapped, 2, SEEK_CUR);
- $this->assertEquals(4, ftell($source));
- $this->assertEquals(4, ftell($wrapped));
-
- fseek($wrapped, -1, SEEK_END);
- $this->assertEquals(5, ftell($source));
- $this->assertEquals(5, ftell($wrapped));
- }
-
- public function testStat() {
- $source = fopen(__FILE__, 'r+');
- $wrapped = $this->wrapSource($source);
- $this->assertEquals(stat(__FILE__), fstat($wrapped));
- }
-
- public function testTruncate() {
- if (version_compare(phpversion(), '5.4.0', '<')) {
- $this->markTestSkipped('php <5.4 doesn\'t support truncate for stream wrappers');
- }
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
- $wrapped = $this->wrapSource($source);
-
- ftruncate($wrapped, 2);
- $this->assertEquals('fo', fread($wrapped, 10));
- }
-
- public function testLock() {
- $source = tmpfile();
- $wrapped = $this->wrapSource($source);
- if (!flock($wrapped, LOCK_EX)) {
- $this->fail('Unable to acquire lock');
- }
- }
-
- public function testStreamOptions() {
- $source = fopen('php://temp', 'r+');
- $wrapped = $this->wrapSource($source);
- stream_set_blocking($wrapped, 0);
- stream_set_timeout($wrapped, 1, 0);
- stream_set_write_buffer($wrapped, 0);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php b/apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php
deleted file mode 100644
index 2c17fd57feb..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-date_default_timezone_set('UTC');
-require_once __DIR__ . '/../vendor/autoload.php';
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml b/apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml
deleted file mode 100644
index e3d96352c43..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<phpunit bootstrap="bootstrap.php">
- <testsuite name='Stream'>
- <directory suffix='.php'>./</directory>
- </testsuite>
-</phpunit>
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index 5e5716cf438..b79f42d1e00 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -490,18 +490,27 @@ class Google extends \OC\Files\Storage\Common {
$path = self::$tempFiles[$tmpFile];
$parentFolder = $this->getDriveFile(dirname($path));
if ($parentFolder) {
- // TODO Research resumable upload
$mimetype = \OC::$server->getMimeTypeDetector()->detect($tmpFile);
- $data = file_get_contents($tmpFile);
$params = array(
- 'data' => $data,
'mimeType' => $mimetype,
'uploadType' => 'media'
);
$result = false;
+
+ $chunkSizeBytes = 10 * 1024 * 1024;
+
+ $useChunking = false;
+ $size = filesize($tmpFile);
+ if ($size > $chunkSizeBytes) {
+ $useChunking = true;
+ } else {
+ $params['data'] = file_get_contents($tmpFile);
+ }
+
if ($this->file_exists($path)) {
$file = $this->getDriveFile($path);
- $result = $this->service->files->update($file->getId(), $file, $params);
+ $this->client->setDefer($useChunking);
+ $request = $this->service->files->update($file->getId(), $file, $params);
} else {
$file = new \Google_Service_Drive_DriveFile();
$file->setTitle(basename($path));
@@ -509,8 +518,46 @@ class Google extends \OC\Files\Storage\Common {
$parent = new \Google_Service_Drive_ParentReference();
$parent->setId($parentFolder->getId());
$file->setParents(array($parent));
- $result = $this->service->files->insert($file, $params);
+ $this->client->setDefer($useChunking);
+ $request = $this->service->files->insert($file, $params);
+ }
+
+ if ($useChunking) {
+ // Create a media file upload to represent our upload process.
+ $media = new \Google_Http_MediaFileUpload(
+ $this->client,
+ $request,
+ 'text/plain',
+ null,
+ true,
+ $chunkSizeBytes
+ );
+ $media->setFileSize($size);
+
+ // Upload the various chunks. $status will be false until the process is
+ // complete.
+ $status = false;
+ $handle = fopen($tmpFile, 'rb');
+ while (!$status && !feof($handle)) {
+ $chunk = fread($handle, $chunkSizeBytes);
+ $status = $media->nextChunk($chunk);
+ }
+
+ // The final value of $status will be the data from the API for the object
+ // that has been uploaded.
+ $result = false;
+ if ($status !== false) {
+ $result = $status;
+ }
+
+ fclose($handle);
+ } else {
+ $result = $request;
}
+
+ // Reset to the client to execute requests immediately in the future.
+ $this->client->setDefer(false);
+
if ($result) {
$this->setDriveFile($path, $result);
}
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 2711b2392e9..5ec7824758f 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -60,6 +60,9 @@
if (fileData.recipientsDisplayName) {
tr.attr('data-share-recipients', fileData.recipientsDisplayName);
}
+ if (fileData.shareTypes) {
+ tr.attr('data-share-types', fileData.shareTypes.join(','));
+ }
return tr;
};
@@ -77,6 +80,7 @@
fileList._getWebdavProperties = function() {
var props = oldGetWebdavProperties.apply(this, arguments);
props.push('{' + NS_OC + '}owner-display-name');
+ props.push('{' + NS_OC + '}share-types');
return props;
};
@@ -88,40 +92,45 @@
if (permissionsProp && permissionsProp.indexOf('S') >= 0) {
data.shareOwner = props['{' + NS_OC + '}owner-display-name'];
}
+
+ var shareTypesProp = props['{' + NS_OC + '}share-types'];
+ if (shareTypesProp) {
+ data.shareTypes = _.chain(shareTypesProp).filter(function(xmlvalue) {
+ return (xmlvalue.namespaceURI === NS_OC && xmlvalue.nodeName.split(':')[1] === 'share-type');
+ }).map(function(xmlvalue) {
+ return parseInt(xmlvalue.textContent || xmlvalue.text, 10);
+ }).value();
+ }
+
return data;
});
// use delegate to catch the case with multiple file lists
fileList.$el.on('fileActionsReady', function(ev){
- var fileList = ev.fileList;
var $files = ev.$files;
- function updateIcons($files) {
- if (!$files) {
- // if none specified, update all
- $files = fileList.$fileList.find('tr');
+ _.each($files, function(file) {
+ var $tr = $(file);
+ var shareTypes = $tr.attr('data-share-types');
+ if (shareTypes) {
+ var hasLink = false;
+ var hasShares = false;
+ _.each(shareTypes.split(',') || [], function(shareType) {
+ shareType = parseInt(shareType, 10);
+ if (shareType === OC.Share.SHARE_TYPE_LINK) {
+ hasLink = true;
+ } else if (shareType === OC.Share.SHARE_TYPE_USER) {
+ hasShares = true;
+ } else if (shareType === OC.Share.SHARE_TYPE_GROUP) {
+ hasShares = true;
+ }
+ });
+ OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink);
}
- _.each($files, function(file) {
- var $tr = $(file);
- var shareStatus = OC.Share.statuses[$tr.data('id')];
- OCA.Sharing.Util._updateFileActionIcon($tr, !!shareStatus, shareStatus && shareStatus.link);
- });
- }
-
- if (!OCA.Sharing.sharesLoaded){
- OC.Share.loadIcons('file', fileList, function() {
- // since we don't know which files are affected, just refresh them all
- updateIcons();
- });
- // assume that we got all shares, so switching directories
- // will not invalidate that list
- OCA.Sharing.sharesLoaded = true;
- }
- else{
- updateIcons($files);
- }
+ });
});
+
fileList.$el.on('changeDirectory', function() {
OCA.Sharing.sharesLoaded = false;
});
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index a799d4a94c2..da0f957ed99 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -286,6 +286,8 @@
// using a hash to make them unique,
// this is only a list to be displayed
data.recipients = {};
+ // share types
+ data.shareTypes = {};
// counter is cheaper than calling _.keys().length
data.recipientsCount = 0;
data.mtime = file.share.stime;
@@ -308,6 +310,8 @@
data.recipientsCount++;
}
+ data.shareTypes[file.share.type] = true;
+
delete file.share;
return memo;
}, {})
@@ -324,6 +328,12 @@
data.recipientsCount
);
delete data.recipientsCount;
+ if (self._sharedWithUser) {
+ // only for outgoing shres
+ delete data.shareTypes;
+ } else {
+ data.shareTypes = _.keys(data.shareTypes);
+ }
})
// Finish the chain by getting the result
.value();
diff --git a/apps/files_sharing/tests/js/shareSpec.js b/apps/files_sharing/tests/js/shareSpec.js
index 7607ada50ba..c488bd94fab 100644
--- a/apps/files_sharing/tests/js/shareSpec.js
+++ b/apps/files_sharing/tests/js/shareSpec.js
@@ -53,35 +53,21 @@ describe('OCA.Sharing.Util tests', function() {
permissions: OC.PERMISSION_ALL,
etag: 'abc',
shareOwner: 'User One',
- isShareMountPoint: false
+ isShareMountPoint: false,
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}];
-
- OCA.Sharing.sharesLoaded = true;
- OC.Share.statuses = {
- 1: {link: false, path: '/subdir'}
- };
});
afterEach(function() {
delete OCA.Sharing.sharesLoaded;
delete OC.Share.droppedDown;
fileList.destroy();
fileList = null;
- OC.Share.statuses = {};
- OC.Share.currentShares = {};
});
describe('Sharing data in table row', function() {
// TODO: test data-permissions, data-share-owner, etc
});
describe('Share action icon', function() {
- beforeEach(function() {
- OC.Share.statuses = {1: {link: false, path: '/subdir'}};
- OCA.Sharing.sharesLoaded = true;
- });
- afterEach(function() {
- OC.Share.statuses = {};
- OCA.Sharing.sharesLoaded = false;
- });
it('do not shows share text when not shared', function() {
var $action, $tr;
OC.Share.statuses = {};
@@ -93,7 +79,8 @@ describe('OCA.Sharing.Util tests', function() {
mimetype: 'httpd/unix-directory',
size: 12,
permissions: OC.PERMISSION_ALL,
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: []
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -111,7 +98,8 @@ describe('OCA.Sharing.Util tests', function() {
mimetype: 'text/plain',
size: 12,
permissions: OC.PERMISSION_ALL,
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -131,7 +119,8 @@ describe('OCA.Sharing.Util tests', function() {
mimetype: 'text/plain',
size: 12,
permissions: OC.PERMISSION_ALL,
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_LINK]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -151,7 +140,8 @@ describe('OCA.Sharing.Util tests', function() {
size: 12,
permissions: OC.PERMISSION_ALL,
shareOwner: 'User One',
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -171,7 +161,8 @@ describe('OCA.Sharing.Util tests', function() {
size: 12,
permissions: OC.PERMISSION_ALL,
recipientsDisplayName: 'User One, User Two',
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php
index 95a05f4ed6f..b56a1b7d2f6 100644
--- a/build/integration/features/bootstrap/WebDav.php
+++ b/build/integration/features/bootstrap/WebDav.php
@@ -190,7 +190,7 @@ trait WebDav {
*/
public function theSingleResponseShouldContainAPropertyWithValue($key, $expectedValue) {
$keys = $this->response;
- if (!isset($keys[$key])) {
+ if (!array_key_exists($key, $keys)) {
throw new \Exception("Cannot find property \"$key\" with \"$expectedValue\"");
}
@@ -200,6 +200,57 @@ trait WebDav {
}
}
+ /**
+ * @Then the response should contain a share-types property with
+ */
+ public function theResponseShouldContainAShareTypesPropertyWith($table)
+ {
+ $keys = $this->response;
+ if (!array_key_exists('{http://owncloud.org/ns}share-types', $keys)) {
+ throw new \Exception("Cannot find property \"{http://owncloud.org/ns}share-types\"");
+ }
+
+ $foundTypes = [];
+ $data = $keys['{http://owncloud.org/ns}share-types'];
+ foreach ($data as $item) {
+ if ($item['name'] !== '{http://owncloud.org/ns}share-type') {
+ throw new \Exception('Invalid property found: "' . $item['name'] . '"');
+ }
+
+ $foundTypes[] = $item['value'];
+ }
+
+ foreach ($table->getRows() as $row) {
+ $key = array_search($row[0], $foundTypes);
+ if ($key === false) {
+ throw new \Exception('Expected type ' . $row[0] . ' not found');
+ }
+
+ unset($foundTypes[$key]);
+ }
+
+ if ($foundTypes !== []) {
+ throw new \Exception('Found more share types then specified: ' . $foundTypes);
+ }
+ }
+
+ /**
+ * @Then the response should contain an empty property :property
+ * @param string $property
+ * @throws \Exception
+ */
+ public function theResponseShouldContainAnEmptyProperty($property) {
+ $properties = $this->response;
+ if (!array_key_exists($property, $properties)) {
+ throw new \Exception("Cannot find property \"$property\"");
+ }
+
+ if ($properties[$property] !== null) {
+ throw new \Exception("Property \"$property\" is not empty");
+ }
+ }
+
+
/*Returns the elements of a propfind, $folderDepth requires 1 to see elements without children*/
public function listFolder($user, $path, $folderDepth, $properties = null){
$fullUrl = substr($this->baseUrl, 0, -4);
diff --git a/build/integration/features/webdav-related.feature b/build/integration/features/webdav-related.feature
index 019df3436f8..ee841f9eb5b 100644
--- a/build/integration/features/webdav-related.feature
+++ b/build/integration/features/webdav-related.feature
@@ -168,3 +168,76 @@ Feature: webdav-related
When As an "user0"
And Downloading file "/myChunkedFile.txt"
Then Downloaded content should be "AAAAABBBBBCCCCC"
+
+ Scenario: A file that is not shared does not have a share-types property
+ Given user "user0" exists
+ And user "user0" created a folder "/test"
+ When as "user0" gets properties of folder "/test" with
+ |{http://owncloud.org/ns}share-types|
+ Then the response should contain an empty property "{http://owncloud.org/ns}share-types"
+
+ Scenario: A file that is shared to a user has a share-types property
+ Given user "user0" exists
+ And user "user1" exists
+ And user "user0" created a folder "/test"
+ And as "user0" creating a share with
+ | path | test |
+ | shareType | 0 |
+ | permissions | 31 |
+ | shareWith | user1 |
+ When as "user0" gets properties of folder "/test" with
+ |{http://owncloud.org/ns}share-types|
+ Then the response should contain a share-types property with
+ | 0 |
+
+ Scenario: A file that is shared to a group has a share-types property
+ Given user "user0" exists
+ And group "group1" exists
+ And user "user0" created a folder "/test"
+ And as "user0" creating a share with
+ | path | test |
+ | shareType | 1 |
+ | permissions | 31 |
+ | shareWith | group1 |
+ When as "user0" gets properties of folder "/test" with
+ |{http://owncloud.org/ns}share-types|
+ Then the response should contain a share-types property with
+ | 1 |
+
+ Scenario: A file that is shared by link has a share-types property
+ Given user "user0" exists
+ And user "user0" created a folder "/test"
+ And as "user0" creating a share with
+ | path | test |
+ | shareType | 3 |
+ | permissions | 31 |
+ When as "user0" gets properties of folder "/test" with
+ |{http://owncloud.org/ns}share-types|
+ Then the response should contain a share-types property with
+ | 3 |
+
+ Scenario: A file that is shared by user,group and link has a share-types property
+ Given user "user0" exists
+ And user "user1" exists
+ And group "group2" exists
+ And user "user0" created a folder "/test"
+ And as "user0" creating a share with
+ | path | test |
+ | shareType | 0 |
+ | permissions | 31 |
+ | shareWith | user1 |
+ And as "user0" creating a share with
+ | path | test |
+ | shareType | 1 |
+ | permissions | 31 |
+ | shareWith | group2 |
+ And as "user0" creating a share with
+ | path | test |
+ | shareType | 3 |
+ | permissions | 31 |
+ When as "user0" gets properties of folder "/test" with
+ |{http://owncloud.org/ns}share-types|
+ Then the response should contain a share-types property with
+ | 0 |
+ | 1 |
+ | 3 |
diff --git a/core/js/systemtags/systemtagsinputfield.js b/core/js/systemtags/systemtagsinputfield.js
index 148d52b57dd..45dc5b7b03e 100644
--- a/core/js/systemtags/systemtagsinputfield.js
+++ b/core/js/systemtags/systemtagsinputfield.js
@@ -320,7 +320,9 @@
*/
_createSearchChoice: function(term) {
term = term.trim();
- if (this.collection.filterByName(term).length) {
+ if (this.collection.filter(function(entry) {
+ return entry.get('name') === term;
+ }).length) {
return;
}
if (!this._newTag) {
diff --git a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js
index aadf0de53f2..22bf0d2c82a 100644
--- a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js
+++ b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js
@@ -85,6 +85,15 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() {
expect(result.userVisible).toEqual(true);
expect(result.userAssignable).toEqual(true);
});
+ it('creates dummy tag when user types non-matching name even with prefix of existing tag', function() {
+ var opts = select2Stub.getCall(0).args[0];
+ var result = opts.createSearchChoice('ab');
+ expect(result.id).toEqual(-1);
+ expect(result.name).toEqual('ab');
+ expect(result.isNew).toEqual(true);
+ expect(result.userVisible).toEqual(true);
+ expect(result.userAssignable).toEqual(true);
+ });
it('creates the real tag and fires select event after user selects the dummy tag', function() {
var selectHandler = sinon.stub();
view.on('select', selectHandler);
diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php
index d6ff160870d..604a607336c 100644
--- a/lib/private/filechunking.php
+++ b/lib/private/filechunking.php
@@ -150,59 +150,21 @@ class OC_FileChunking {
* Assembles the chunks into the file specified by the path.
* Also triggers the relevant hooks and proxies.
*
- * @param \OC\Files\Storage\Storage $storage
+ * @param \OC\Files\Storage\Storage $storage storage
* @param string $path target path relative to the storage
- * @param string $absolutePath
- * @return bool assembled file size or false if file could not be created
+ * @return bool true on success or false if file could not be created
*
* @throws \OC\ServerNotAvailableException
*/
- public function file_assemble($storage, $path, $absolutePath) {
- $data = '';
+ public function file_assemble($storage, $path) {
// use file_put_contents as method because that best matches what this function does
if (\OC\Files\Filesystem::isValidPath($path)) {
- $exists = $storage->file_exists($path);
- $run = true;
- $hookPath = \OC\Files\Filesystem::getView()->getRelativePath($absolutePath);
- if(!$exists) {
- OC_Hook::emit(
- \OC\Files\Filesystem::CLASSNAME,
- \OC\Files\Filesystem::signal_create,
- array(
- \OC\Files\Filesystem::signal_param_path => $hookPath,
- \OC\Files\Filesystem::signal_param_run => &$run
- )
- );
- }
- OC_Hook::emit(
- \OC\Files\Filesystem::CLASSNAME,
- \OC\Files\Filesystem::signal_write,
- array(
- \OC\Files\Filesystem::signal_param_path => $hookPath,
- \OC\Files\Filesystem::signal_param_run => &$run
- )
- );
- if(!$run) {
- return false;
- }
$target = $storage->fopen($path, 'w');
- if($target) {
+ if ($target) {
$count = $this->assemble($target);
fclose($target);
- if(!$exists) {
- OC_Hook::emit(
- \OC\Files\Filesystem::CLASSNAME,
- \OC\Files\Filesystem::signal_post_create,
- array( \OC\Files\Filesystem::signal_param_path => $hookPath)
- );
- }
- OC_Hook::emit(
- \OC\Files\Filesystem::CLASSNAME,
- \OC\Files\Filesystem::signal_post_write,
- array( \OC\Files\Filesystem::signal_param_path => $hookPath)
- );
return $count > 0;
- }else{
+ } else {
return false;
}
}