summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/l10n/fr.js4
-rw-r--r--lib/l10n/fr.json4
-rw-r--r--lib/l10n/gl.js6
-rw-r--r--lib/l10n/gl.json6
-rw-r--r--lib/private/defaults.php15
-rw-r--r--lib/private/files/cache/cache.php3
-rw-r--r--lib/private/files/cache/scanner.php194
-rw-r--r--lib/private/files/filesystem.php9
-rw-r--r--lib/private/httphelper.php3
-rw-r--r--lib/private/installer.php2
-rw-r--r--lib/private/json.php46
-rw-r--r--lib/private/urlgenerator.php8
-rw-r--r--lib/private/util.php9
-rw-r--r--lib/public/json.php215
14 files changed, 301 insertions, 223 deletions
diff --git a/lib/l10n/fr.js b/lib/l10n/fr.js
index 6e86a0fb4fb..c2c5556ed18 100644
--- a/lib/l10n/fr.js
+++ b/lib/l10n/fr.js
@@ -93,7 +93,7 @@ OC.L10N.register(
"Setting permissions for %s failed, because the permissions exceed permissions granted to %s" : "Le réglage des permissions pour %s a échoué car les permissions dépassent celles accordées à %s",
"Setting permissions for %s failed, because the item was not found" : "Le réglage des permissions pour %s a échoué car l'objet n'a pas été trouvé",
"Cannot set expiration date. Shares cannot expire later than %s after they have been shared" : "Impossible de configurer la date d'expiration. Un partage ne peut expirer plus de %s après sa création",
- "Cannot set expiration date. Expiration date is in the past" : "Impossible de configurer la date d'expiration. La date d'expiration est dans le passé.",
+ "Cannot set expiration date. Expiration date is in the past" : "Impossible de configurer la date d'expiration : elle est dans le passé.",
"Sharing backend %s must implement the interface OCP\\Share_Backend" : "Le service de partage %s doit implémenter l'interface OCP\\Share_Backend",
"Sharing backend %s not found" : "Service de partage %s non trouvé",
"Sharing backend for %s not found" : "Le service de partage pour %s est introuvable",
@@ -108,12 +108,12 @@ OC.L10N.register(
"A valid password must be provided" : "Un mot de passe valide doit être saisi",
"The username is already being used" : "Ce nom d'utilisateur est déjà utilisé",
"No database drivers (sqlite, mysql, or postgresql) installed." : "Aucun pilote de base de données (sqlite, mysql, ou postgresql) n’est installé.",
- "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Les permissions peuvent, généralement, être résolues %sen donnant au serveur web un accès en écriture au répertoire racine%s",
"Cannot write into \"config\" directory" : "Impossible d’écrire dans le répertoire \"config\"",
"Cannot write into \"apps\" directory" : "Impossible d’écrire dans le répertoire \"apps\"",
"This can usually be fixed by %sgiving the webserver write access to the apps directory%s or disabling the appstore in the config file." : "Ce problème est généralement résolu %sen donnant au serveur web un accès en écriture au répertoire apps%s ou en désactivant l'appstore dans le fichier de configuration.",
"Cannot create \"data\" directory (%s)" : "Impossible de créer le répertoire \"data\" (%s)",
"This can usually be fixed by <a href=\"%s\" target=\"_blank\">giving the webserver write access to the root directory</a>." : "Ce problème est généralement résolu <a href=\"%s\" target=\"_blank\">en donnant au serveur web un accès en écriture au répertoire racine</a>.",
+ "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Les permissions peuvent, généralement, être résolues %sen donnant au serveur web un accès en écriture au répertoire racine%s",
"Setting locale to %s failed" : "Le choix de la langue pour %s a échoué",
"Please install one of these locales on your system and restart your webserver." : "Veuillez installer l'un de ces paramètres régionaux sur votre système et redémarrer votre serveur web.",
"Please ask your server administrator to install the module." : "Veuillez demander à votre administrateur d’installer le module.",
diff --git a/lib/l10n/fr.json b/lib/l10n/fr.json
index 46384b46402..4be87a0d4df 100644
--- a/lib/l10n/fr.json
+++ b/lib/l10n/fr.json
@@ -91,7 +91,7 @@
"Setting permissions for %s failed, because the permissions exceed permissions granted to %s" : "Le réglage des permissions pour %s a échoué car les permissions dépassent celles accordées à %s",
"Setting permissions for %s failed, because the item was not found" : "Le réglage des permissions pour %s a échoué car l'objet n'a pas été trouvé",
"Cannot set expiration date. Shares cannot expire later than %s after they have been shared" : "Impossible de configurer la date d'expiration. Un partage ne peut expirer plus de %s après sa création",
- "Cannot set expiration date. Expiration date is in the past" : "Impossible de configurer la date d'expiration. La date d'expiration est dans le passé.",
+ "Cannot set expiration date. Expiration date is in the past" : "Impossible de configurer la date d'expiration : elle est dans le passé.",
"Sharing backend %s must implement the interface OCP\\Share_Backend" : "Le service de partage %s doit implémenter l'interface OCP\\Share_Backend",
"Sharing backend %s not found" : "Service de partage %s non trouvé",
"Sharing backend for %s not found" : "Le service de partage pour %s est introuvable",
@@ -106,12 +106,12 @@
"A valid password must be provided" : "Un mot de passe valide doit être saisi",
"The username is already being used" : "Ce nom d'utilisateur est déjà utilisé",
"No database drivers (sqlite, mysql, or postgresql) installed." : "Aucun pilote de base de données (sqlite, mysql, ou postgresql) n’est installé.",
- "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Les permissions peuvent, généralement, être résolues %sen donnant au serveur web un accès en écriture au répertoire racine%s",
"Cannot write into \"config\" directory" : "Impossible d’écrire dans le répertoire \"config\"",
"Cannot write into \"apps\" directory" : "Impossible d’écrire dans le répertoire \"apps\"",
"This can usually be fixed by %sgiving the webserver write access to the apps directory%s or disabling the appstore in the config file." : "Ce problème est généralement résolu %sen donnant au serveur web un accès en écriture au répertoire apps%s ou en désactivant l'appstore dans le fichier de configuration.",
"Cannot create \"data\" directory (%s)" : "Impossible de créer le répertoire \"data\" (%s)",
"This can usually be fixed by <a href=\"%s\" target=\"_blank\">giving the webserver write access to the root directory</a>." : "Ce problème est généralement résolu <a href=\"%s\" target=\"_blank\">en donnant au serveur web un accès en écriture au répertoire racine</a>.",
+ "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Les permissions peuvent, généralement, être résolues %sen donnant au serveur web un accès en écriture au répertoire racine%s",
"Setting locale to %s failed" : "Le choix de la langue pour %s a échoué",
"Please install one of these locales on your system and restart your webserver." : "Veuillez installer l'un de ces paramètres régionaux sur votre système et redémarrer votre serveur web.",
"Please ask your server administrator to install the module." : "Veuillez demander à votre administrateur d’installer le module.",
diff --git a/lib/l10n/gl.js b/lib/l10n/gl.js
index 6a6704799ff..8fa89bae6b4 100644
--- a/lib/l10n/gl.js
+++ b/lib/l10n/gl.js
@@ -108,19 +108,19 @@ OC.L10N.register(
"A valid password must be provided" : "Debe fornecer un contrasinal",
"The username is already being used" : "Este nome de usuario xa está a ser usado",
"No database drivers (sqlite, mysql, or postgresql) installed." : "Non hay controladores de base de datos (sqlite, mysql, ou postgresql) instalados.",
- "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Polo xeral, isto pode ser fixado para %spermitirlle ao servidor web acceso de escritura ao directorio «root»%s.",
"Cannot write into \"config\" directory" : "Non é posíbel escribir no directorio «config»",
"Cannot write into \"apps\" directory" : "Non é posíbel escribir no directorio «apps»",
"This can usually be fixed by %sgiving the webserver write access to the apps directory%s or disabling the appstore in the config file." : "Polo xeral, isto pode ser fixado para %spermitirlle ao servidor web acceso de escritura ao directorio «apps»%s ou a desactivación da «appstore» no ficheiro de configuración.",
"Cannot create \"data\" directory (%s)" : "Non é posíbel crear o directorio «data» (%s)",
"This can usually be fixed by <a href=\"%s\" target=\"_blank\">giving the webserver write access to the root directory</a>." : "Polo xeral, isto pode ser fixado para <a href=\"%s\" target=\"_blank\">permitirlle ao servidor web acceso de escritura ao directorio «root»</a>.",
+ "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Polo xeral, isto pode ser fixado para %spermitirlle ao servidor web acceso de escritura ao directorio «root»%s.",
"Setting locale to %s failed" : "Fallou o axuste da configuración local a %s",
"Please install one of these locales on your system and restart your webserver." : "Instale unha destas configuracións locais no seu sistema e reinicie o servidor web.",
"Please ask your server administrator to install the module." : "Pregúntelle ao administrador do servidor pola instalación do módulo.",
"PHP module %s not installed." : "O módulo PHP %s non está instalado.",
"Please ask your server administrator to update PHP to the latest version. Your PHP version is no longer supported by ownCloud and the PHP community." : "Pregúntelle ao administrador do servidor pola actualización de PHP á versión máis recente. A súa versión de PHP xa non é asistida polas comunidades de ownCloud e PHP.",
- "PHP is configured to populate raw post data. Since PHP 5.6 this will lead to PHP throwing notices for perfectly valid code." : "PHP está configurado para surtir datos de código en bruto. Desde PHP 5.6 esto levará a que PHP proporcione avisos con código perfectamente válido.",
- "To fix this issue set <code>always_populate_raw_post_data</code> to <code>-1</code> in your php.ini" : "Para solucionar este asunto estableza <code>always_populate_raw_post_data</code> a <code>-1</code> no seu php.ini",
+ "PHP is configured to populate raw post data. Since PHP 5.6 this will lead to PHP throwing notices for perfectly valid code." : "PHP está configurado para encher datos de código en bruto. Desde PHP 5.6 isto levará a que PHP forneza avisos con código perfectamente correcto.",
+ "To fix this issue set <code>always_populate_raw_post_data</code> to <code>-1</code> in your php.ini" : "Para solucionar este problema estabeleza <code>always_populate_raw_post_data</code> a <code>-1</code> no seu php.ini",
"PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible." : "Parece que PHP foi configuración para substituír bloques de documentos en liña. Isto fará que varias aplicacións sexan inaccesíbeis.",
"This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Isto probabelmente se debe unha caché/acelerador como Zend OPcache ou eAccelerator.",
"PHP modules have been installed, but they are still listed as missing?" : "Instaláronse os módulos de PHP, mais aínda aparecen listados como perdidos?",
diff --git a/lib/l10n/gl.json b/lib/l10n/gl.json
index c9feefa2f53..9c8992ddeac 100644
--- a/lib/l10n/gl.json
+++ b/lib/l10n/gl.json
@@ -106,19 +106,19 @@
"A valid password must be provided" : "Debe fornecer un contrasinal",
"The username is already being used" : "Este nome de usuario xa está a ser usado",
"No database drivers (sqlite, mysql, or postgresql) installed." : "Non hay controladores de base de datos (sqlite, mysql, ou postgresql) instalados.",
- "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Polo xeral, isto pode ser fixado para %spermitirlle ao servidor web acceso de escritura ao directorio «root»%s.",
"Cannot write into \"config\" directory" : "Non é posíbel escribir no directorio «config»",
"Cannot write into \"apps\" directory" : "Non é posíbel escribir no directorio «apps»",
"This can usually be fixed by %sgiving the webserver write access to the apps directory%s or disabling the appstore in the config file." : "Polo xeral, isto pode ser fixado para %spermitirlle ao servidor web acceso de escritura ao directorio «apps»%s ou a desactivación da «appstore» no ficheiro de configuración.",
"Cannot create \"data\" directory (%s)" : "Non é posíbel crear o directorio «data» (%s)",
"This can usually be fixed by <a href=\"%s\" target=\"_blank\">giving the webserver write access to the root directory</a>." : "Polo xeral, isto pode ser fixado para <a href=\"%s\" target=\"_blank\">permitirlle ao servidor web acceso de escritura ao directorio «root»</a>.",
+ "Permissions can usually be fixed by %sgiving the webserver write access to the root directory%s." : "Polo xeral, isto pode ser fixado para %spermitirlle ao servidor web acceso de escritura ao directorio «root»%s.",
"Setting locale to %s failed" : "Fallou o axuste da configuración local a %s",
"Please install one of these locales on your system and restart your webserver." : "Instale unha destas configuracións locais no seu sistema e reinicie o servidor web.",
"Please ask your server administrator to install the module." : "Pregúntelle ao administrador do servidor pola instalación do módulo.",
"PHP module %s not installed." : "O módulo PHP %s non está instalado.",
"Please ask your server administrator to update PHP to the latest version. Your PHP version is no longer supported by ownCloud and the PHP community." : "Pregúntelle ao administrador do servidor pola actualización de PHP á versión máis recente. A súa versión de PHP xa non é asistida polas comunidades de ownCloud e PHP.",
- "PHP is configured to populate raw post data. Since PHP 5.6 this will lead to PHP throwing notices for perfectly valid code." : "PHP está configurado para surtir datos de código en bruto. Desde PHP 5.6 esto levará a que PHP proporcione avisos con código perfectamente válido.",
- "To fix this issue set <code>always_populate_raw_post_data</code> to <code>-1</code> in your php.ini" : "Para solucionar este asunto estableza <code>always_populate_raw_post_data</code> a <code>-1</code> no seu php.ini",
+ "PHP is configured to populate raw post data. Since PHP 5.6 this will lead to PHP throwing notices for perfectly valid code." : "PHP está configurado para encher datos de código en bruto. Desde PHP 5.6 isto levará a que PHP forneza avisos con código perfectamente correcto.",
+ "To fix this issue set <code>always_populate_raw_post_data</code> to <code>-1</code> in your php.ini" : "Para solucionar este problema estabeleza <code>always_populate_raw_post_data</code> a <code>-1</code> no seu php.ini",
"PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible." : "Parece que PHP foi configuración para substituír bloques de documentos en liña. Isto fará que varias aplicacións sexan inaccesíbeis.",
"This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Isto probabelmente se debe unha caché/acelerador como Zend OPcache ou eAccelerator.",
"PHP modules have been installed, but they are still listed as missing?" : "Instaláronse os módulos de PHP, mais aínda aparecen listados como perdidos?",
diff --git a/lib/private/defaults.php b/lib/private/defaults.php
index c16ebdbe24c..dfcd97aedd6 100644
--- a/lib/private/defaults.php
+++ b/lib/private/defaults.php
@@ -1,9 +1,5 @@
<?php
-if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php')) {
- require_once 'themes/' . OC_Util::getTheme() . '/defaults.php';
-}
-
/**
* Default strings and values which differ between the enterprise and the
* community edition. Use the get methods to always get the right strings.
@@ -45,8 +41,15 @@ class OC_Defaults {
$this->defaultLogoClaim = '';
$this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */
- if (class_exists('OC_Theme')) {
- $this->theme = new OC_Theme();
+ $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
+ if (file_exists($themePath)) {
+ // prevent defaults.php from printing output
+ ob_start();
+ require_once $themePath;
+ ob_end_clean();
+ if (class_exists('OC_Theme')) {
+ $this->theme = new OC_Theme();
+ }
}
}
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 06a884072e0..48b2b5c024b 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -193,6 +193,9 @@ class Cache {
$file['size'] = $file['unencrypted_size'];
}
$file['permissions'] = (int)$file['permissions'];
+ $file['mtime'] = (int)$file['mtime'];
+ $file['storage_mtime'] = (int)$file['storage_mtime'];
+ $file['size'] = 0 + $file['size'];
}
return $files;
} else {
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 4778a6803ba..d369398af1c 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -80,7 +80,8 @@ class Scanner extends BasicEmitter {
* @return array an array of metadata of the file
*/
public function getData($path) {
- if (!$this->storage->isReadable($path)) {
+ $permissions = $this->storage->getPermissions($path);
+ if (!$permissions & \OCP\PERMISSION_READ) {
//cant read, nothing we can do
\OCP\Util::writeLog('OC\Files\Cache\Scanner', "!!! Path '$path' is not accessible or present !!!", \OCP\Util::DEBUG);
return null;
@@ -95,7 +96,7 @@ class Scanner extends BasicEmitter {
}
$data['etag'] = $this->storage->getETag($path);
$data['storage_mtime'] = $data['mtime'];
- $data['permissions'] = $this->storage->getPermissions($path);
+ $data['permissions'] = $permissions;
return $data;
}
@@ -104,9 +105,11 @@ class Scanner extends BasicEmitter {
*
* @param string $file
* @param int $reuseExisting
+ * @param int $parentId
+ * @param array | null $cacheData existing data in the cache for the file to be scanned
* @return array an array of metadata of the scanned file
*/
- public function scanFile($file, $reuseExisting = 0) {
+ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null) {
if (!self::isPartialFile($file)
and !Filesystem::isFileBlacklisted($file)
) {
@@ -118,7 +121,9 @@ class Scanner extends BasicEmitter {
if ($parent === '.' or $parent === '/') {
$parent = '';
}
- $parentId = $this->cache->getId($parent);
+ if ($parentId === -1) {
+ $parentId = $this->cache->getId($parent);
+ }
// scan the parent if it's not in the cache (id -1) and the current file is not the root folder
if ($file and $parentId === -1) {
@@ -128,14 +133,18 @@ class Scanner extends BasicEmitter {
if ($parent) {
$data['parent'] = $parentId;
}
- $cacheData = $this->cache->get($file);
- if ($cacheData and $reuseExisting) {
+ if (is_null($cacheData)) {
+ $cacheData = $this->cache->get($file);
+ }
+ if ($cacheData and $reuseExisting and isset($cacheData['fileid'])) {
// prevent empty etag
if (empty($cacheData['etag'])) {
$etag = $data['etag'];
} else {
$etag = $cacheData['etag'];
}
+ $fileId = $cacheData['fileid'];
+ $data['fileid'] = $fileId;
// only reuse data if the file hasn't explicitly changed
if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_mtime']) {
$data['mtime'] = $cacheData['mtime'];
@@ -150,9 +159,10 @@ class Scanner extends BasicEmitter {
$newData = array_diff_assoc($data, $cacheData);
} else {
$newData = $data;
+ $fileId = -1;
}
if (!empty($newData)) {
- $data['fileid'] = $this->addToCache($file, $newData);
+ $data['fileid'] = $this->addToCache($file, $newData, $fileId);
$this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId));
\OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId));
}
@@ -175,13 +185,19 @@ class Scanner extends BasicEmitter {
/**
* @param string $path
* @param array $data
+ * @param int $fileId
* @return int the id of the added file
*/
- protected function addToCache($path, $data) {
+ protected function addToCache($path, $data, $fileId = -1) {
\OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'data' => $data));
$this->emit('\OC\Files\Cache\Scanner', 'addToCache', array($path, $this->storageId, $data));
if ($this->cacheActive) {
- return $this->cache->put($path, $data);
+ if ($fileId !== -1) {
+ $this->cache->update($fileId, $data);
+ return $fileId;
+ } else {
+ return $this->cache->put($path, $data);
+ }
} else {
return -1;
}
@@ -190,12 +206,17 @@ class Scanner extends BasicEmitter {
/**
* @param string $path
* @param array $data
+ * @param int $fileId
*/
- protected function updateCache($path, $data) {
+ protected function updateCache($path, $data, $fileId = -1) {
\OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'data' => $data));
$this->emit('\OC\Files\Cache\Scanner', 'updateCache', array($path, $this->storageId, $data));
if ($this->cacheActive) {
- $this->cache->put($path, $data);
+ if ($fileId !== -1) {
+ $this->cache->update($fileId, $data);
+ } else {
+ $this->cache->put($path, $data);
+ }
}
}
@@ -212,97 +233,124 @@ class Scanner extends BasicEmitter {
$reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
}
$data = $this->scanFile($path, $reuse);
- if ($data !== null) {
- $size = $this->scanChildren($path, $recursive, $reuse);
+ if ($data and $data['mimetype'] === 'httpd/unix-directory') {
+ $size = $this->scanChildren($path, $recursive, $reuse, $data);
$data['size'] = $size;
}
return $data;
}
- protected function getExistingChildren($path) {
+ /**
+ * Get the children currently in the cache
+ *
+ * @param int $folderId
+ * @return array[]
+ */
+ protected function getExistingChildren($folderId) {
$existingChildren = array();
- if ($this->cache->inCache($path)) {
- $children = $this->cache->getFolderContents($path);
- foreach ($children as $child) {
- $existingChildren[] = $child['name'];
- }
+ $children = $this->cache->getFolderContentsById($folderId);
+ foreach ($children as $child) {
+ $existingChildren[$child['name']] = $child;
}
return $existingChildren;
}
/**
+ * Get the children from the storage
+ *
+ * @param string $folder
+ * @return string[]
+ */
+ protected function getNewChildren($folder) {
+ $children = array();
+ if ($dh = $this->storage->opendir($folder)) {
+ if (is_resource($dh)) {
+ while (($file = readdir($dh)) !== false) {
+ if (!Filesystem::isIgnoredDir($file)) {
+ $children[] = $file;
+ }
+ }
+ }
+ }
+ return $children;
+ }
+
+ /**
* scan all the files and folders in a folder
*
* @param string $path
* @param bool $recursive
* @param int $reuse
+ * @param array $folderData existing cache data for the folder to be scanned
* @return int the size of the scanned folder or -1 if the size is unknown at this stage
*/
- public function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1) {
+ protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderData = null) {
if ($reuse === -1) {
$reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
}
$this->emit('\OC\Files\Cache\Scanner', 'scanFolder', array($path, $this->storageId));
$size = 0;
$childQueue = array();
- $existingChildren = $this->getExistingChildren($path);
- $newChildren = array();
- if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
- $exceptionOccurred = false;
- if ($this->useTransactions) {
- \OC_DB::beginTransaction();
- }
- if (is_resource($dh)) {
- while (($file = readdir($dh)) !== false) {
- $child = ($path) ? $path . '/' . $file : $file;
- if (!Filesystem::isIgnoredDir($file)) {
- $newChildren[] = $file;
- try {
- $data = $this->scanFile($child, $reuse);
- if ($data) {
- if ($data['mimetype'] === 'httpd/unix-directory' and $recursive === self::SCAN_RECURSIVE) {
- $childQueue[] = $child;
- } else if ($data['size'] === -1) {
- $size = -1;
- } else if ($size !== -1) {
- $size += $data['size'];
- }
- }
- } catch (\Doctrine\DBAL\DBALException $ex) {
- // might happen if inserting duplicate while a scanning
- // process is running in parallel
- // log and ignore
- \OC_Log::write('core', 'Exception while scanning file "' . $child . '": ' . $ex->getMessage(), \OC_Log::DEBUG);
- $exceptionOccurred = true;
- }
+ if (is_array($folderData) and isset($folderData['fileid'])) {
+ $folderId = $folderData['fileid'];
+ } else {
+ $folderId = $this->cache->getId($path);
+ }
+ $existingChildren = $this->getExistingChildren($folderId);
+ $newChildren = $this->getNewChildren($path);
+
+ if ($this->useTransactions) {
+ \OC_DB::beginTransaction();
+ }
+ $exceptionOccurred = false;
+ foreach ($newChildren as $file) {
+ $child = ($path) ? $path . '/' . $file : $file;
+ try {
+ $existingData = isset($existingChildren[$file]) ? $existingChildren[$file] : null;
+ $data = $this->scanFile($child, $reuse, $folderId, $existingData);
+ if ($data) {
+ if ($data['mimetype'] === 'httpd/unix-directory' and $recursive === self::SCAN_RECURSIVE) {
+ $childQueue[$child] = $data;
+ } else if ($data['size'] === -1) {
+ $size = -1;
+ } else if ($size !== -1) {
+ $size += $data['size'];
}
}
+ } catch (\Doctrine\DBAL\DBALException $ex) {
+ // might happen if inserting duplicate while a scanning
+ // process is running in parallel
+ // log and ignore
+ \OC_Log::write('core', 'Exception while scanning file "' . $child . '": ' . $ex->getMessage(), \OC_Log::DEBUG);
+ $exceptionOccurred = true;
}
- $removedChildren = \array_diff($existingChildren, $newChildren);
- foreach ($removedChildren as $childName) {
- $child = ($path) ? $path . '/' . $childName : $childName;
- $this->removeFromCache($child);
- }
- if ($this->useTransactions) {
- \OC_DB::commit();
- }
- if ($exceptionOccurred) {
- // It might happen that the parallel scan process has already
- // inserted mimetypes but those weren't available yet inside the transaction
- // To make sure to have the updated mime types in such cases,
- // we reload them here
- $this->cache->loadMimetypes();
- }
+ }
+ $removedChildren = \array_diff(array_keys($existingChildren), $newChildren);
+ foreach ($removedChildren as $childName) {
+ $child = ($path) ? $path . '/' . $childName : $childName;
+ $this->removeFromCache($child);
+ }
+ if ($this->useTransactions) {
+ \OC_DB::commit();
+ }
+ if ($exceptionOccurred) {
+ // It might happen that the parallel scan process has already
+ // inserted mimetypes but those weren't available yet inside the transaction
+ // To make sure to have the updated mime types in such cases,
+ // we reload them here
+ $this->cache->loadMimetypes();
+ }
- foreach ($childQueue as $child) {
- $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE, $reuse);
- if ($childSize === -1) {
- $size = -1;
- } else if ($size !== -1) {
- $size += $childSize;
- }
+ foreach ($childQueue as $child => $childData) {
+ $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE, $reuse, $childData);
+ if ($childSize === -1) {
+ $size = -1;
+ } else if ($size !== -1) {
+ $size += $childSize;
}
- $this->updateCache($path, array('size' => $size));
+ }
+ if (!is_array($folderData) or !isset($folderData['size']) or $folderData['size'] !== $size) {
+ $this->updateCache($path, array('size' => $size), $folderId);
}
$this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', array($path, $this->storageId));
return $size;
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index e933782ce2f..04f82d88cd1 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -723,9 +723,18 @@ class Filesystem {
* Fix common problems with a file path
* @param string $path
* @param bool $stripTrailingSlash
+ * @param bool $isAbsolutePath
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false) {
+ /**
+ * FIXME: This is a workaround for existing classes and files which call
+ * this function with another type than a valid string. This
+ * conversion should get removed as soon as all existing
+ * function calls have been fixed.
+ */
+ $path = (string)$path;
+
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath]);
if(isset(self::$normalizedPathCache[$cacheKey])) {
diff --git a/lib/private/httphelper.php b/lib/private/httphelper.php
index 1f3482b3514..08c35e4ae08 100644
--- a/lib/private/httphelper.php
+++ b/lib/private/httphelper.php
@@ -214,7 +214,8 @@ class HTTPHelper {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, count($fields));
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, (string)$fieldsString);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
if (is_readable($certBundle)) {
curl_setopt($ch, CURLOPT_CAINFO, $certBundle);
}
diff --git a/lib/private/installer.php b/lib/private/installer.php
index b4fbe527b4f..db8f27aeeab 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -241,7 +241,7 @@ class OC_Installer{
if(!isset($data['href'])) {
throw new \Exception($l->t("No href specified when installing app from http"));
}
- copy($data['href'], $path);
+ file_put_contents($path, \OC_Util::getUrlContent($data['href']));
}else{
if(!isset($data['path'])) {
throw new \Exception($l->t("No path specified when installing app from local file"));
diff --git a/lib/private/json.php b/lib/private/json.php
index f2719dd2bc7..9117abf7fb9 100644
--- a/lib/private/json.php
+++ b/lib/private/json.php
@@ -6,10 +6,15 @@
* See the COPYING-README file.
*/
+/**
+ * Class OC_JSON
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
class OC_JSON{
static protected $send_content_type_header = false;
/**
* set Content-Type header to jsonrequest
+ * @deprecated Use a AppFramework JSONResponse instead
*/
public static function setContentTypeHeader($type='application/json') {
if (!self::$send_content_type_header) {
@@ -20,9 +25,10 @@ class OC_JSON{
}
/**
- * Check if the app is enabled, send json error msg if not
- * @param string $app
- */
+ * Check if the app is enabled, send json error msg if not
+ * @param string $app
+ * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
+ */
public static function checkAppEnabled($app) {
if( !OC_App::isEnabled($app)) {
$l = \OC::$server->getL10N('lib');
@@ -32,8 +38,9 @@ class OC_JSON{
}
/**
- * Check if the user is logged in, send json error msg if not
- */
+ * Check if the user is logged in, send json error msg if not
+ * @deprecated Use annotation based ACLs from the AppFramework instead
+ */
public static function checkLoggedIn() {
if( !OC_User::isLoggedIn()) {
$l = \OC::$server->getL10N('lib');
@@ -44,6 +51,7 @@ class OC_JSON{
/**
* Check an ajax get/post call if the request token is valid, send json error msg if not.
+ * @deprecated Use annotation based CSRF checks from the AppFramework instead
*/
public static function callCheck() {
if( !OC_Util::isCallRegistered()) {
@@ -54,8 +62,9 @@ class OC_JSON{
}
/**
- * Check if the user is a admin, send json error msg if not.
- */
+ * Check if the user is a admin, send json error msg if not.
+ * @deprecated Use annotation based ACLs from the AppFramework instead
+ */
public static function checkAdminUser() {
if( !OC_User::isAdminUser(OC_User::getUser())) {
$l = \OC::$server->getL10N('lib');
@@ -67,6 +76,7 @@ class OC_JSON{
/**
* Check is a given user exists - send json error msg if not
* @param string $user
+ * @deprecated Use a AppFramework JSONResponse instead
*/
public static function checkUserExists($user) {
if (!OCP\User::userExists($user)) {
@@ -77,10 +87,10 @@ class OC_JSON{
}
-
/**
- * Check if the user is a subadmin, send json error msg if not
- */
+ * Check if the user is a subadmin, send json error msg if not
+ * @deprecated Use annotation based ACLs from the AppFramework instead
+ */
public static function checkSubAdminUser() {
if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
$l = \OC::$server->getL10N('lib');
@@ -90,16 +100,18 @@ class OC_JSON{
}
/**
- * Send json error msg
- */
+ * Send json error msg
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
public static function error($data = array()) {
$data['status'] = 'error';
self::encodedPrint($data);
}
/**
- * Send json success msg
- */
+ * Send json success msg
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
public static function success($data = array()) {
$data['status'] = 'success';
self::encodedPrint($data);
@@ -115,8 +127,9 @@ class OC_JSON{
}
/**
- * Encode and print $data in json format
- */
+ * Encode and print $data in json format
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
public static function encodedPrint($data, $setContentType=true) {
if($setContentType) {
self::setContentTypeHeader();
@@ -126,6 +139,7 @@ class OC_JSON{
/**
* Encode JSON
+ * @deprecated Use a AppFramework JSONResponse instead
*/
public static function encode($data) {
if (is_array($data)) {
diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php
index d263d25aeef..0bf8ce22998 100644
--- a/lib/private/urlgenerator.php
+++ b/lib/private/urlgenerator.php
@@ -32,8 +32,7 @@ class URLGenerator implements IURLGenerator {
/**
* Creates an url using a defined route
* @param string $route
- * @param array $parameters
- * @internal param array $args with param=>value, will be appended to the returned url
+ * @param array $parameters args with param=>value, will be appended to the returned url
* @return string the url
*
* Returns a url to the given route.
@@ -45,9 +44,8 @@ class URLGenerator implements IURLGenerator {
/**
* Creates an absolute url using a defined route
- * @param string $route
- * @param array $parameters
- * @internal param array $args with param=>value, will be appended to the returned url
+ * @param string $routeName
+ * @param array $arguments args with param=>value, will be appended to the returned url
* @return string the url
*
* Returns an absolute url to the given route.
diff --git a/lib/private/util.php b/lib/private/util.php
index d6c76e0960c..2be7e8eb293 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -504,11 +504,6 @@ class OC_Util {
$webServerRestart = true;
}
- //common hint for all file permissions error messages
- $permissionsHint = $l->t('Permissions can usually be fixed by '
- . '%sgiving the webserver write access to the root directory%s.',
- array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'));
-
// Check if config folder is writable.
if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) {
$errors[] = array(
@@ -549,6 +544,10 @@ class OC_Util {
);
}
} else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
+ //common hint for all file permissions error messages
+ $permissionsHint = $l->t('Permissions can usually be fixed by '
+ . '%sgiving the webserver write access to the root directory%s.',
+ array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'));
$errors[] = array(
'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud',
'hint' => $permissionsHint
diff --git a/lib/public/json.php b/lib/public/json.php
index e7371ad63f3..5d9675e5ba4 100644
--- a/lib/public/json.php
+++ b/lib/public/json.php
@@ -23,7 +23,6 @@
/**
* Public interface of ownCloud for apps to use.
* JSON Class
- *
*/
// use OCP namespace for all classes that are considered public.
@@ -31,141 +30,142 @@
namespace OCP;
/**
- * This class provides convinient functions to generate and send JSON data. Usefull for Ajax calls
+ * This class provides convenient functions to generate and send JSON data. Useful for Ajax calls
+ * @deprecated Use a AppFramework JSONResponse instead
*/
class JSON {
/**
- * Encode and print $data in JSON format
- * @param array $data The data to use
- * @param string $setContentType the optional content type
- * @return string json formatted string.
- */
+ * Encode and print $data in JSON format
+ * @param array $data The data to use
+ * @param bool $setContentType the optional content type
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
public static function encodedPrint( $data, $setContentType=true ) {
- return(\OC_JSON::encodedPrint( $data, $setContentType ));
+ \OC_JSON::encodedPrint($data, $setContentType);
}
/**
- * Check if the user is logged in, send json error msg if not.
- *
- * This method checks if a user is logged in. If not, a json error
- * response will be return and the method will exit from execution
- * of the script.
- * The returned json will be in the format:
- *
- * {"status":"error","data":{"message":"Authentication error."}}
- *
- * Add this call to the start of all ajax method files that requires
- * an authenticated user.
- *
- * @return string json formatted error string if not authenticated.
- */
+ * Check if the user is logged in, send json error msg if not.
+ *
+ * This method checks if a user is logged in. If not, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Authentication error."}}
+ *
+ * Add this call to the start of all ajax method files that requires
+ * an authenticated user.
+ * @deprecated Use annotation based ACLs from the AppFramework instead
+ */
public static function checkLoggedIn() {
- return(\OC_JSON::checkLoggedIn());
+ \OC_JSON::checkLoggedIn();
}
/**
- * Check an ajax get/post call if the request token is valid.
- *
- * This method checks for a valid variable 'requesttoken' in $_GET,
- * $_POST and $_SERVER. If a valid token is not found, a json error
- * response will be return and the method will exit from execution
- * of the script.
- * The returned json will be in the format:
- *
- * {"status":"error","data":{"message":"Token expired. Please reload page."}}
- *
- * Add this call to the start of all ajax method files that creates,
- * updates or deletes anything.
- * In cases where you e.g. use an ajax call to load a dialog containing
- * a submittable form, you will need to add the requesttoken first as a
- * parameter to the ajax call, then assign it to the template and finally
- * add a hidden input field also named 'requesttoken' containing the value.
- *
- * @return \json|null json formatted error string if not valid.
- */
+ * Check an ajax get/post call if the request token is valid.
+ *
+ * This method checks for a valid variable 'requesttoken' in $_GET,
+ * $_POST and $_SERVER. If a valid token is not found, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Token expired. Please reload page."}}
+ *
+ * Add this call to the start of all ajax method files that creates,
+ * updates or deletes anything.
+ * In cases where you e.g. use an ajax call to load a dialog containing
+ * a submittable form, you will need to add the requesttoken first as a
+ * parameter to the ajax call, then assign it to the template and finally
+ * add a hidden input field also named 'requesttoken' containing the value.
+ * @deprecated Use annotation based CSRF checks from the AppFramework instead
+ */
public static function callCheck() {
- return(\OC_JSON::callCheck());
+ \OC_JSON::callCheck();
}
/**
- * Send json success msg
- *
- * Return a json success message with optional extra data.
- * @see OCP\JSON::error() for the format to use.
- *
- * @param array $data The data to use
- * @return string json formatted string.
- */
+ * Send json success msg
+ *
+ * Return a json success message with optional extra data.
+ * @see OCP\JSON::error() for the format to use.
+ *
+ * @param array $data The data to use
+ * @return string json formatted string.
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
public static function success( $data = array() ) {
- return(\OC_JSON::success( $data ));
+ \OC_JSON::success($data);
}
/**
- * Send json error msg
- *
- * Return a json error message with optional extra data for
- * error message or app specific data.
- *
- * Example use:
- *
- * $id = [some value]
- * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id)));
- *
- * Will return the json formatted string:
- *
- * {"status":"error","data":{"message":"An error happened", "id":[some value]}}
- *
- * @param array $data The data to use
- * @return string json formatted error string.
- */
+ * Send json error msg
+ *
+ * Return a json error message with optional extra data for
+ * error message or app specific data.
+ *
+ * Example use:
+ *
+ * $id = [some value]
+ * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id)));
+ *
+ * Will return the json formatted string:
+ *
+ * {"status":"error","data":{"message":"An error happened", "id":[some value]}}
+ *
+ * @param array $data The data to use
+ * @return string json formatted error string.
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
public static function error( $data = array() ) {
- return(\OC_JSON::error( $data ));
+ \OC_JSON::error( $data );
}
/**
- * Set Content-Type header to jsonrequest
- * @param array $type The contwnt type header
- * @return string json formatted string.
- */
+ * Set Content-Type header to jsonrequest
+ * @param string $type The content type header
+ * @deprecated Use a AppFramework JSONResponse instead
+ */
public static function setContentTypeHeader( $type='application/json' ) {
- return(\OC_JSON::setContentTypeHeader( $type ));
+ \OC_JSON::setContentTypeHeader($type);
}
/**
- * Check if the App is enabled and send JSON error message instead
- *
- * This method checks if a specific app is enabled. If not, a json error
- * response will be return and the method will exit from execution
- * of the script.
- * The returned json will be in the format:
- *
- * {"status":"error","data":{"message":"Application is not enabled."}}
- *
- * Add this call to the start of all ajax method files that requires
- * a specific app to be enabled.
- *
- * @param string $app The app to check
- * @return string json formatted string if not enabled.
- */
+ * Check if the App is enabled and send JSON error message instead
+ *
+ * This method checks if a specific app is enabled. If not, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Application is not enabled."}}
+ *
+ * Add this call to the start of all ajax method files that requires
+ * a specific app to be enabled.
+ *
+ * @param string $app The app to check
+ * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
+ */
public static function checkAppEnabled( $app ) {
- return(\OC_JSON::checkAppEnabled( $app ));
+ \OC_JSON::checkAppEnabled($app);
}
/**
- * Check if the user is a admin, send json error msg if not
- *
- * This method checks if the current user has admin rights. If not, a json error
- * response will be return and the method will exit from execution
- * of the script.
- * The returned json will be in the format:
- *
- * {"status":"error","data":{"message":"Authentication error."}}
- *
- * Add this call to the start of all ajax method files that requires
- * administrative rights.
- *
- * @return string json formatted string if not admin user.
- */
+ * Check if the user is a admin, send json error msg if not
+ *
+ * This method checks if the current user has admin rights. If not, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Authentication error."}}
+ *
+ * Add this call to the start of all ajax method files that requires
+ * administrative rights.
+ *
+ * @deprecated Use annotation based ACLs from the AppFramework instead
+ */
public static function checkAdminUser() {
\OC_JSON::checkAdminUser();
}
@@ -173,14 +173,17 @@ class JSON {
/**
* Encode JSON
* @param array $data
+ * @return string
+ * @deprecated Use a AppFramework JSONResponse instead
*/
public static function encode($data) {
- return(\OC_JSON::encode($data));
+ return \OC_JSON::encode($data);
}
/**
* Check is a given user exists - send json error msg if not
* @param string $user
+ * @deprecated Use a AppFramework JSONResponse instead
*/
public static function checkUserExists($user) {
\OC_JSON::checkUserExists($user);