summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorroot <roger.szabo@web.de>2016-07-27 15:17:29 +0800
committerroot <roger.szabo@web.de>2016-07-27 15:17:29 +0800
commit2719dcabed16954c7c01114e7a6357089556ad78 (patch)
treebe77987507ad9a51afd10a2c1a14bd92c5b17ad0 /lib
parent1c64ee67afb41f3d3872f1ad59d5c3c900394bbb (diff)
parent95a0714973b4b6b95658c2904a0de7ba93c8eab9 (diff)
downloadnextcloud-server-2719dcabed16954c7c01114e7a6357089556ad78.tar.gz
nextcloud-server-2719dcabed16954c7c01114e7a6357089556ad78.zip
Merge branch 'master' of https://github.com/nextcloud/server
Diffstat (limited to 'lib')
-rw-r--r--lib/l10n/cs_CZ.js1
-rw-r--r--lib/l10n/cs_CZ.json1
-rw-r--r--lib/private/AppFramework/DependencyInjection/DIContainer.php6
-rw-r--r--lib/private/Files/Node/Folder.php78
-rw-r--r--lib/private/Files/Node/LazyRoot.php7
-rw-r--r--lib/private/Files/Storage/Wrapper/Jail.php2
-rw-r--r--lib/private/Log.php7
-rw-r--r--lib/private/Log/File.php (renamed from lib/private/Log/Owncloud.php)2
-rw-r--r--lib/private/Server.php5
-rw-r--r--lib/private/legacy/app.php2
-rw-r--r--lib/public/Files/FileInfo.php5
-rw-r--r--lib/public/Files/Folder.php8
12 files changed, 117 insertions, 7 deletions
diff --git a/lib/l10n/cs_CZ.js b/lib/l10n/cs_CZ.js
index f6e4fe6f099..2a5faddedaf 100644
--- a/lib/l10n/cs_CZ.js
+++ b/lib/l10n/cs_CZ.js
@@ -115,6 +115,7 @@ OC.L10N.register(
"The username is already being used" : "Uživatelské jméno je již využíváno",
"Login canceled by app" : "Přihlášení zrušeno aplikací",
"User disabled" : "Uživatel zakázán",
+ "Help" : "Nápověda",
"Personal" : "Osobní",
"Users" : "Uživatelé",
"Admin" : "Administrace",
diff --git a/lib/l10n/cs_CZ.json b/lib/l10n/cs_CZ.json
index ead413190b1..9b964100551 100644
--- a/lib/l10n/cs_CZ.json
+++ b/lib/l10n/cs_CZ.json
@@ -113,6 +113,7 @@
"The username is already being used" : "Uživatelské jméno je již využíváno",
"Login canceled by app" : "Přihlášení zrušeno aplikací",
"User disabled" : "Uživatel zakázán",
+ "Help" : "Nápověda",
"Personal" : "Osobní",
"Users" : "Uživatelé",
"Admin" : "Administrace",
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php
index 59803d02bee..ab360bf2395 100644
--- a/lib/private/AppFramework/DependencyInjection/DIContainer.php
+++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php
@@ -330,6 +330,12 @@ class DIContainer extends SimpleContainer implements IAppContainer {
);
});
+ /**
+ * App Framework default arguments
+ */
+ $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH');
+ $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept');
+ $this->registerParameter('corsMaxAge', 1728000);
/**
* Middleware
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index 8813b6c0775..e67e4817e2a 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -26,7 +26,10 @@
namespace OC\Files\Node;
+use OC\DB\QueryBuilder\Literal;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\FileInfo;
+use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
@@ -358,4 +361,79 @@ class Folder extends Node implements \OCP\Files\Folder {
$uniqueName = \OC_Helper::buildNotExistingFileNameForView($this->getPath(), $name, $this->view);
return trim($this->getRelativePath($uniqueName), '/');
}
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return \OCP\Files\Node[]
+ */
+ public function getRecent($limit, $offset = 0) {
+ $mimetypeLoader = \OC::$server->getMimeTypeLoader();
+ $mounts = $this->root->getMountsIn($this->path);
+ $mounts[] = $this->getMountPoint();
+
+ $mounts = array_filter($mounts, function (IMountPoint $mount) {
+ return $mount->getStorage();
+ });
+ $storageIds = array_map(function (IMountPoint $mount) {
+ return $mount->getStorage()->getCache()->getNumericStorageId();
+ }, $mounts);
+ /** @var IMountPoint[] $mountMap */
+ $mountMap = array_combine($storageIds, $mounts);
+ $folderMimetype = $mimetypeLoader->getId(FileInfo::MIMETYPE_FOLDER);
+
+ //todo look into options of filtering path based on storage id (only search in files/ for home storage, filter by share root for shared, etc)
+
+ $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $query = $builder
+ ->select('f.*')
+ ->from('filecache', 'f')
+ ->andWhere($builder->expr()->in('f.storage', $builder->createNamedParameter($storageIds, IQueryBuilder::PARAM_INT_ARRAY)))
+ ->andWhere($builder->expr()->orX(
+ // handle non empty folders separate
+ $builder->expr()->neq('f.mimetype', $builder->createNamedParameter($folderMimetype, IQueryBuilder::PARAM_INT)),
+ $builder->expr()->eq('f.size', new Literal(0))
+ ))
+ ->orderBy('f.mtime', 'DESC')
+ ->setMaxResults($limit)
+ ->setFirstResult($offset);
+
+ $result = $query->execute()->fetchAll();
+
+ $files = array_filter(array_map(function (array $entry) use ($mountMap, $mimetypeLoader) {
+ $mount = $mountMap[$entry['storage']];
+ $entry['internalPath'] = $entry['path'];
+ $entry['mimetype'] = $mimetypeLoader->getMimetypeById($entry['mimetype']);
+ $entry['mimepart'] = $mimetypeLoader->getMimetypeById($entry['mimepart']);
+ $path = $this->getAbsolutePath($mount, $entry['path']);
+ if (is_null($path)) {
+ return null;
+ }
+ $fileInfo = new \OC\Files\FileInfo($path, $mount->getStorage(), $entry['internalPath'], $entry, $mount);
+ return $this->root->createNode($fileInfo->getPath(), $fileInfo);
+ }, $result));
+
+ return array_values(array_filter($files, function (Node $node) {
+ $relative = $this->getRelativePath($node->getPath());
+ return $relative !== null && $relative !== '/';
+ }));
+ }
+
+ private function getAbsolutePath(IMountPoint $mount, $path) {
+ $storage = $mount->getStorage();
+ if ($storage->instanceOfStorage('\OC\Files\Storage\Wrapper\Jail')) {
+ /** @var \OC\Files\Storage\Wrapper\Jail $storage */
+ $jailRoot = $storage->getSourcePath('');
+ $rootLength = strlen($jailRoot) + 1;
+ if ($path === $jailRoot) {
+ return $mount->getMountPoint();
+ } else if (substr($path, 0, $rootLength) === $jailRoot . '/') {
+ return $mount->getMountPoint() . substr($path, $rootLength);
+ } else {
+ return null;
+ }
+ } else {
+ return $mount->getMountPoint() . $path;
+ }
+ }
}
diff --git a/lib/private/Files/Node/LazyRoot.php b/lib/private/Files/Node/LazyRoot.php
index 1203fc4d162..317b8144653 100644
--- a/lib/private/Files/Node/LazyRoot.php
+++ b/lib/private/Files/Node/LazyRoot.php
@@ -471,5 +471,10 @@ class LazyRoot implements IRootFolder {
return $this->__call(__FUNCTION__, func_get_args());
}
-
+ /**
+ * @inheritDoc
+ */
+ public function getRecent($limit, $offset = 0) {
+ return $this->__call(__FUNCTION__, func_get_args());
+ }
}
diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php
index 80c75523748..5b9085799b9 100644
--- a/lib/private/Files/Storage/Wrapper/Jail.php
+++ b/lib/private/Files/Storage/Wrapper/Jail.php
@@ -377,7 +377,7 @@ class Jail extends Wrapper {
*/
public function getCache($path = '', $storage = null) {
if (!$storage) {
- $storage = $this;
+ $storage = $this->storage;
}
$sourceCache = $this->storage->getCache($this->getSourcePath($path), $storage);
return new CacheJail($sourceCache, $this->rootPath);
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 59233cf5c12..0a707f3d4ea 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -103,7 +103,12 @@ class Log implements ILogger {
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
if($logger === null) {
- $this->logger = 'OC\\Log\\'.ucfirst($this->config->getValue('log_type', 'owncloud'));
+ // TODO: Drop backwards compatibility for config in the future
+ $logType = $this->config->getValue('log_type', 'file');
+ if($logType==='owncloud') {
+ $logType = 'file';
+ }
+ $this->logger = 'OC\\Log\\'.ucfirst($logType);
call_user_func(array($this->logger, 'init'));
} else {
$this->logger = $logger;
diff --git a/lib/private/Log/Owncloud.php b/lib/private/Log/File.php
index 2cc70015e3c..a406dd83952 100644
--- a/lib/private/Log/Owncloud.php
+++ b/lib/private/Log/File.php
@@ -39,7 +39,7 @@ namespace OC\Log;
* Log is saved at data/nextcloud.log (on default)
*/
-class Owncloud {
+class File {
static protected $logFile;
/**
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 16a6ee3ba64..fd6ecdc297e 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -365,8 +365,9 @@ class Server extends ServerContainer implements IServerContainer {
);
});
$this->registerService('Logger', function (Server $c) {
- $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud');
- $logger = 'OC\\Log\\' . ucfirst($logClass);
+ $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'file');
+ // TODO: Drop backwards compatibility for config in the future
+ $logger = 'OC\\Log\\' . ucfirst($logClass=='owncloud' ? 'file' : $logClass);
call_user_func(array($logger, 'init'));
return new Log($logger);
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 4cfa68cff2d..5395d1daeee 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -169,7 +169,7 @@ class OC_App {
// Register on PSR-4 composer autoloader
$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
- if (defined('PHPUNIT_RUN')) {
+ if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
}
diff --git a/lib/public/Files/FileInfo.php b/lib/public/Files/FileInfo.php
index d61726c4217..04790d41556 100644
--- a/lib/public/Files/FileInfo.php
+++ b/lib/public/Files/FileInfo.php
@@ -59,6 +59,11 @@ interface FileInfo {
const SPACE_UNLIMITED = -3;
/**
+ * @since 9.1.0
+ */
+ const MIMETYPE_FOLDER = 'httpd/unix-directory';
+
+ /**
* Get the Etag of the file or folder
*
* @return string
diff --git a/lib/public/Files/Folder.php b/lib/public/Files/Folder.php
index 9a2a338b559..8f8576d8503 100644
--- a/lib/public/Files/Folder.php
+++ b/lib/public/Files/Folder.php
@@ -175,4 +175,12 @@ interface Folder extends Node {
* @since 8.1.0
*/
public function getNonExistingName($name);
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return \OCP\Files\Node[]
+ * @since 9.1.0
+ */
+ public function getRecent($limit, $offset = 0);
}