aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Collaboration/AutoComplete/Manager.php81
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php10
-rw-r--r--lib/private/Files/ObjectStore/S3ObjectTrait.php13
-rw-r--r--lib/private/Files/Type/Detection.php4
-rw-r--r--lib/private/Files/View.php24
-rw-r--r--lib/private/Server.php10
-rw-r--r--lib/private/Share20/Manager.php2
-rw-r--r--lib/private/legacy/app.php2
8 files changed, 137 insertions, 9 deletions
diff --git a/lib/private/Collaboration/AutoComplete/Manager.php b/lib/private/Collaboration/AutoComplete/Manager.php
new file mode 100644
index 00000000000..eedc4fb5b40
--- /dev/null
+++ b/lib/private/Collaboration/AutoComplete/Manager.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Collaboration\AutoComplete;
+
+use OCP\Collaboration\AutoComplete\IManager;
+use OCP\Collaboration\AutoComplete\ISorter;
+use OCP\IServerContainer;
+
+class Manager implements IManager {
+ /** @var string[] */
+ protected $sorters =[];
+
+ /** @var ISorter[] */
+ protected $sorterInstances = [];
+ /** @var IServerContainer */
+ private $c;
+
+ public function __construct(IServerContainer $container) {
+ $this->c = $container;
+ }
+
+ public function runSorters(array $sorters, array &$sortArray, array $context) {
+ $sorterInstances = $this->getSorters();
+ while($sorter = array_shift($sorters)) {
+ if(isset($sorterInstances[$sorter])) {
+ $sorterInstances[$sorter]->sort($sortArray, $context);
+ } else {
+ $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [
+ 'app' => 'core', 'id' => $sorter
+ ]);
+ }
+ }
+ }
+
+ public function registerSorter($className) {
+ $this->sorters[] = $className;
+ }
+
+ protected function getSorters() {
+ if(count($this->sorterInstances) === 0) {
+ foreach ($this->sorters as $sorter) {
+ /** @var ISorter $instance */
+ $instance = $this->c->resolve($sorter);
+ if(!$instance instanceof ISorter) {
+ $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}',
+ ['app' => 'core', 'class' => $sorter]);
+ continue;
+ }
+ $sorterId = trim($instance->getId());
+ if(trim($sorterId) === '') {
+ $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}',
+ ['app' => 'core', 'class' => $sorter]);
+ continue;
+ }
+ $this->sorterInstances[$sorterId] = $instance;
+ }
+ }
+ return $this->sorterInstances;
+ }
+}
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index ded69e8079b..15df808684b 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -390,7 +390,15 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$stat['size'] = filesize($tmpFile);
$stat['mtime'] = $mTime;
$stat['storage_mtime'] = $mTime;
- $stat['mimetype'] = \OC::$server->getMimeTypeDetector()->detect($tmpFile);
+
+ // run path based detection first, to use file extension because $tmpFile is only a random string
+ $mimetypeDetector = \OC::$server->getMimeTypeDetector();
+ $mimetype = $mimetypeDetector->detectPath($path);
+ if ($mimetype === 'application/octet-stream') {
+ $mimetype = $mimetypeDetector->detect($tmpFile);
+ }
+
+ $stat['mimetype'] = $mimetype;
$stat['etag'] = $this->getETag($path);
$fileId = $this->getCache()->put($path, $stat);
diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php
index 6fb12265cb7..4bfa08a3e59 100644
--- a/lib/private/Files/ObjectStore/S3ObjectTrait.php
+++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php
@@ -49,12 +49,15 @@ trait S3ObjectTrait {
'Bucket' => $this->bucket,
'Key' => $urn
]);
- $command['@http']['stream'] = true;
- $result = $client->execute($command);
- /** @var StreamInterface $body */
- $body = $result['Body'];
+ $request = \Aws\serialize($command);
+ $opts = [
+ 'http' => [
+ 'header' => $request->getHeaders()
+ ]
+ ];
- return $body->detach();
+ $context = stream_context_create($opts);
+ return fopen($request->getUri(), 'r', false, $context);
}
/**
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php
index cd4ddc2f067..928c68251cf 100644
--- a/lib/private/Files/Type/Detection.php
+++ b/lib/private/Files/Type/Detection.php
@@ -173,6 +173,10 @@ class Detection implements IMimeTypeDetector {
// note: leading dot doesn't qualify as extension
if (strpos($fileName, '.') > 0) {
+
+ // remove versioning extension: name.v1508946057 and transfer extension: name.ocTransferId2057600214.part
+ $fileName = preg_replace('!((\.v\d+)|((.ocTransferId\d+)?.part))$!', '', $fileName);
+
//try to guess the type by the file extension
$extension = strtolower(strrchr($fileName, '.'));
$extension = substr($extension, 1); //remove leading .
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 7fee0883a25..d69f3b45fd2 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -447,8 +447,28 @@ class View {
@ob_end_clean();
$handle = $this->fopen($path, 'rb');
if ($handle) {
- if (fseek($handle, $from) === 0) {
- $chunkSize = 8192; // 8 kB chunks
+ $chunkSize = 8192; // 8 kB chunks
+ $startReading = true;
+
+ if ($from !== 0 && $from !== '0' && fseek($handle, $from) !== 0) {
+ // forward file handle via chunked fread because fseek seem to have failed
+
+ $end = $from + 1;
+ while (!feof($handle) && ftell($handle) < $end) {
+ $len = $from - ftell($handle);
+ if ($len > $chunkSize) {
+ $len = $chunkSize;
+ }
+ $result = fread($handle, $len);
+
+ if ($result === false) {
+ $startReading = false;
+ break;
+ }
+ }
+ }
+
+ if ($startReading) {
$end = $to + 1;
while (!feof($handle) && ftell($handle) < $end) {
$len = $end - ftell($handle);
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 84c09c8e6db..c461d3842cd 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -106,6 +106,7 @@ use OCA\Theming\ThemingDefaults;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Collaboration\AutoComplete\IManager;
use OCP\Defaults;
use OCA\Theming\Util;
use OCP\Federation\ICloudIdManager;
@@ -1011,6 +1012,8 @@ class Server extends ServerContainer implements IServerContainer {
});
$this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
+ $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
+
$this->registerService('SettingsManager', function (Server $c) {
$manager = new \OC\Settings\Manager(
$c->getLogger(),
@@ -1802,6 +1805,13 @@ class Server extends ServerContainer implements IServerContainer {
}
/**
+ * @return \OCP\Collaboration\AutoComplete\IManager
+ */
+ public function getAutoCompleteManager(){
+ return $this->query(IManager::class);
+ }
+
+ /**
* Returns the LDAP Provider
*
* @return \OCP\LDAP\ILDAPProvider
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index bcef85bd17a..379d87633ab 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1322,7 +1322,7 @@ class Manager implements IManager {
*
* @param \OCP\Files\Node $path
* @param bool $recursive Should we check all parent folders as well
- * @param bool $currentAccess Should the user have currently access to the file
+ * @param bool $currentAccess Ensure the recipient has access to the file (e.g. did not unshare it)
* @return array
*/
public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false) {
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 519bb2cad2e..49fac2f4d96 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -185,6 +185,8 @@ class OC_App {
'class' => $plugin['@value'],
];
\OC::$server->getCollaboratorSearch()->registerPlugin($pluginInfo);
+ } else if ($plugin['@attributes']['type'] === 'autocomplete-sort') {
+ \OC::$server->getAutoCompleteManager()->registerSorter($plugin['@value']);
}
}
}