summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/l10n/es_CL.js2
-rw-r--r--lib/l10n/es_CL.json2
-rw-r--r--lib/l10n/es_CO.js2
-rw-r--r--lib/l10n/es_CO.json2
-rw-r--r--lib/l10n/es_CR.js2
-rw-r--r--lib/l10n/es_CR.json2
-rw-r--r--lib/l10n/es_DO.js2
-rw-r--r--lib/l10n/es_DO.json2
-rw-r--r--lib/l10n/es_EC.js2
-rw-r--r--lib/l10n/es_EC.json2
-rw-r--r--lib/l10n/es_GT.js2
-rw-r--r--lib/l10n/es_GT.json2
-rw-r--r--lib/l10n/es_SV.js2
-rw-r--r--lib/l10n/es_SV.json2
-rw-r--r--lib/private/Files/Config/UserMountCache.php51
-rw-r--r--lib/private/Files/Mount/Manager.php50
-rw-r--r--lib/private/Files/View.php20
-rw-r--r--lib/private/Preview/HEIC.php108
-rw-r--r--lib/private/Share20/Manager.php4
-rw-r--r--lib/private/legacy/app.php2
20 files changed, 197 insertions, 66 deletions
diff --git a/lib/l10n/es_CL.js b/lib/l10n/es_CL.js
index ed7dcfac93d..df6c2ef4140 100644
--- a/lib/l10n/es_CL.js
+++ b/lib/l10n/es_CL.js
@@ -58,7 +58,7 @@ OC.L10N.register(
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Chile)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_CL.json b/lib/l10n/es_CL.json
index 1f4040a51fc..238ed0295bb 100644
--- a/lib/l10n/es_CL.json
+++ b/lib/l10n/es_CL.json
@@ -56,7 +56,7 @@
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Chile)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_CO.js b/lib/l10n/es_CO.js
index ed7dcfac93d..9af7b8be461 100644
--- a/lib/l10n/es_CO.js
+++ b/lib/l10n/es_CO.js
@@ -58,7 +58,7 @@ OC.L10N.register(
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Colombia)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_CO.json b/lib/l10n/es_CO.json
index 1f4040a51fc..a8b25e626c5 100644
--- a/lib/l10n/es_CO.json
+++ b/lib/l10n/es_CO.json
@@ -56,7 +56,7 @@
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Colombia)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_CR.js b/lib/l10n/es_CR.js
index ed7dcfac93d..74000ba74b8 100644
--- a/lib/l10n/es_CR.js
+++ b/lib/l10n/es_CR.js
@@ -58,7 +58,7 @@ OC.L10N.register(
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Costa Rica)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_CR.json b/lib/l10n/es_CR.json
index 1f4040a51fc..804922deb4a 100644
--- a/lib/l10n/es_CR.json
+++ b/lib/l10n/es_CR.json
@@ -56,7 +56,7 @@
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Costa Rica)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_DO.js b/lib/l10n/es_DO.js
index ed7dcfac93d..db9089aa785 100644
--- a/lib/l10n/es_DO.js
+++ b/lib/l10n/es_DO.js
@@ -58,7 +58,7 @@ OC.L10N.register(
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Dominican Republic)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_DO.json b/lib/l10n/es_DO.json
index 1f4040a51fc..0f173fb4fb0 100644
--- a/lib/l10n/es_DO.json
+++ b/lib/l10n/es_DO.json
@@ -56,7 +56,7 @@
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Dominican Republic)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_EC.js b/lib/l10n/es_EC.js
index ed7dcfac93d..5eff8d8d37d 100644
--- a/lib/l10n/es_EC.js
+++ b/lib/l10n/es_EC.js
@@ -58,7 +58,7 @@ OC.L10N.register(
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Ecuador)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_EC.json b/lib/l10n/es_EC.json
index 1f4040a51fc..a62906134c9 100644
--- a/lib/l10n/es_EC.json
+++ b/lib/l10n/es_EC.json
@@ -56,7 +56,7 @@
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Ecuador)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_GT.js b/lib/l10n/es_GT.js
index ed7dcfac93d..3f8d4509b92 100644
--- a/lib/l10n/es_GT.js
+++ b/lib/l10n/es_GT.js
@@ -58,7 +58,7 @@ OC.L10N.register(
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Guatemala)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_GT.json b/lib/l10n/es_GT.json
index 1f4040a51fc..febf89a632e 100644
--- a/lib/l10n/es_GT.json
+++ b/lib/l10n/es_GT.json
@@ -56,7 +56,7 @@
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Guatemala)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_SV.js b/lib/l10n/es_SV.js
index ed7dcfac93d..acd3d325b1f 100644
--- a/lib/l10n/es_SV.js
+++ b/lib/l10n/es_SV.js
@@ -58,7 +58,7 @@ OC.L10N.register(
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (El Salvador)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/l10n/es_SV.json b/lib/l10n/es_SV.json
index 1f4040a51fc..64edc8826c1 100644
--- a/lib/l10n/es_SV.json
+++ b/lib/l10n/es_SV.json
@@ -56,7 +56,7 @@
"Empty filename is not allowed" : "El uso de nombres de archivo vacíos no está permitido",
"App \"%s\" cannot be installed because appinfo file cannot be read." : "La aplicación \"%s\" no puede ser instalada porque el archivo appinfo no se puede leer. ",
"App \"%s\" cannot be installed because it is not compatible with this version of the server." : "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión del servidor. ",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (El Salvador)",
"This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no lo contestes. ",
"Help" : "Ayuda",
"Apps" : "Aplicaciones",
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php
index a6741652308..63abdf5fdeb 100644
--- a/lib/private/Files/Config/UserMountCache.php
+++ b/lib/private/Files/Config/UserMountCache.php
@@ -101,17 +101,31 @@ class UserMountCache implements IUserMountCache {
}
}, $mounts);
$newMounts = array_values(array_filter($newMounts));
+ $newMountRootIds = array_map(function (ICachedMountInfo $mount) {
+ return $mount->getRootId();
+ }, $newMounts);
+ $newMounts = array_combine($newMountRootIds, $newMounts);
$cachedMounts = $this->getMountsForUser($user);
- $mountDiff = function (ICachedMountInfo $mount1, ICachedMountInfo $mount2) {
- // since we are only looking for mounts for a specific user comparing on root id is enough
- return $mount1->getRootId() - $mount2->getRootId();
- };
+ $cachedMountRootIds = array_map(function (ICachedMountInfo $mount) {
+ return $mount->getRootId();
+ }, $cachedMounts);
+ $cachedMounts = array_combine($cachedMountRootIds, $cachedMounts);
- /** @var ICachedMountInfo[] $addedMounts */
- $addedMounts = array_udiff($newMounts, $cachedMounts, $mountDiff);
- /** @var ICachedMountInfo[] $removedMounts */
- $removedMounts = array_udiff($cachedMounts, $newMounts, $mountDiff);
+ $addedMounts = [];
+ $removedMounts = [];
+
+ foreach ($newMounts as $rootId => $newMount) {
+ if (!isset($cachedMounts[$rootId])) {
+ $addedMounts[] = $newMount;
+ }
+ }
+
+ foreach ($cachedMounts as $rootId => $cachedMount) {
+ if (!isset($newMounts[$rootId])) {
+ $removedMounts[] = $cachedMount;
+ }
+ }
$changedMounts = $this->findChangedMounts($newMounts, $cachedMounts);
@@ -135,16 +149,19 @@ class UserMountCache implements IUserMountCache {
* @return ICachedMountInfo[]
*/
private function findChangedMounts(array $newMounts, array $cachedMounts) {
+ $new = [];
+ foreach ($newMounts as $mount) {
+ $new[$mount->getRootId()] = $mount;
+ }
$changed = [];
- foreach ($newMounts as $newMount) {
- foreach ($cachedMounts as $cachedMount) {
+ foreach ($cachedMounts as $cachedMount) {
+ $rootId = $cachedMount->getRootId();
+ if (isset($new[$rootId])) {
+ $newMount = $new[$rootId];
if (
- $newMount->getRootId() === $cachedMount->getRootId() &&
- (
- $newMount->getMountPoint() !== $cachedMount->getMountPoint() ||
- $newMount->getStorageId() !== $cachedMount->getStorageId() ||
- $newMount->getMountId() !== $cachedMount->getMountId()
- )
+ $newMount->getMountPoint() !== $cachedMount->getMountPoint() ||
+ $newMount->getStorageId() !== $cachedMount->getStorageId() ||
+ $newMount->getMountId() !== $cachedMount->getMountId()
) {
$changed[] = $newMount;
}
@@ -197,7 +214,7 @@ class UserMountCache implements IUserMountCache {
}
$mount_id = $row['mount_id'];
if (!is_null($mount_id)) {
- $mount_id = (int) $mount_id;
+ $mount_id = (int)$mount_id;
}
return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $mount_id, isset($row['path']) ? $row['path'] : '');
}
diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php
index 019dda03a40..1293b8549a5 100644
--- a/lib/private/Files/Mount/Manager.php
+++ b/lib/private/Files/Mount/Manager.php
@@ -38,8 +38,12 @@ class Manager implements IMountManager {
/** @var CappedMemoryCache */
private $pathCache;
+ /** @var CappedMemoryCache */
+ private $inPathCache;
+
public function __construct() {
$this->pathCache = new CappedMemoryCache();
+ $this->inPathCache = new CappedMemoryCache();
}
/**
@@ -48,6 +52,7 @@ class Manager implements IMountManager {
public function addMount(IMountPoint $mount) {
$this->mounts[$mount->getMountPoint()] = $mount;
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**
@@ -60,16 +65,18 @@ class Manager implements IMountManager {
}
unset($this->mounts[$mountPoint]);
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**
* @param string $mountPoint
* @param string $target
*/
- public function moveMount(string $mountPoint, string $target){
+ public function moveMount(string $mountPoint, string $target) {
$this->mounts[$target] = $this->mounts[$mountPoint];
unset($this->mounts[$mountPoint]);
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**
@@ -80,32 +87,29 @@ class Manager implements IMountManager {
*/
public function find(string $path) {
\OC_Util::setupFS();
- $path = $this->formatPath($path);
- if (isset($this->mounts[$path])) {
- return $this->mounts[$path];
- }
+ $path = Filesystem::normalizePath($path);
if (isset($this->pathCache[$path])) {
return $this->pathCache[$path];
}
- \OC_Hook::emit('OC_Filesystem', 'get_mountpoint', ['path' => $path]);
- $foundMountPoint = '';
- $mountPoints = array_keys($this->mounts);
- $foundMountPointLength = 0;
- foreach ($mountPoints as $mountpoint) {
- if (\strlen($mountpoint) > $foundMountPointLength && strpos($path, $mountpoint) === 0) {
- $foundMountPoint = $mountpoint;
- $foundMountPointLength = \strlen($foundMountPoint);
+ $current = $path;
+ while (true) {
+ $mountPoint = $current . '/';
+ if (isset($this->mounts[$mountPoint])) {
+ $this->pathCache[$path] = $this->mounts[$mountPoint];
+ return $this->mounts[$mountPoint];
}
- }
- if (isset($this->mounts[$foundMountPoint])) {
- $this->pathCache[$path] = $this->mounts[$foundMountPoint];
- return $this->mounts[$foundMountPoint];
- }
+ if ($current === '') {
+ return null;
+ }
- return null;
+ $current = dirname($current);
+ if ($current === '.' || $current === '/') {
+ $current = '';
+ }
+ }
}
/**
@@ -117,6 +121,11 @@ class Manager implements IMountManager {
public function findIn(string $path): array {
\OC_Util::setupFS();
$path = $this->formatPath($path);
+
+ if (isset($this->inPathCache[$path])) {
+ return $this->inPathCache[$path];
+ }
+
$result = [];
$pathLength = \strlen($path);
$mountPoints = array_keys($this->mounts);
@@ -125,12 +134,15 @@ class Manager implements IMountManager {
$result[] = $this->mounts[$mountPoint];
}
}
+
+ $this->inPathCache[$path] = $result;
return $result;
}
public function clear() {
$this->mounts = [];
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index c6429a89942..19e38717803 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -1433,16 +1433,21 @@ class View {
$contents = $cache->getFolderContentsById($folderId); //TODO: mimetype_filter
$sharingDisabled = \OCP\Util::isSharingDisabledForUser();
+
+ $fileNames = array_map(function(ICacheEntry $content) {
+ return $content->getName();
+ }, $contents);
/**
- * @var \OC\Files\FileInfo[] $files
+ * @var \OC\Files\FileInfo[] $fileInfos
*/
- $files = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
+ $fileInfos = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
if ($sharingDisabled) {
$content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
}
$owner = $this->getUserObjectForOwner($storage->getOwner($content['path']));
return new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner);
}, $contents);
+ $files = array_combine($fileNames, $fileInfos);
//add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders
$mounts = Filesystem::getMountManager()->findIn($path);
@@ -1496,13 +1501,6 @@ class View {
$rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE));
}
- //remove any existing entry with the same name
- foreach ($files as $i => $file) {
- if ($file['name'] === $rootEntry['name']) {
- unset($files[$i]);
- break;
- }
- }
$rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/
// if sharing was disabled for the user we remove the share permissions
@@ -1511,7 +1509,7 @@ class View {
}
$owner = $this->getUserObjectForOwner($subStorage->getOwner(''));
- $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
+ $files[$rootEntry->getName()] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
}
}
}
@@ -1527,7 +1525,7 @@ class View {
});
}
- return $files;
+ return array_values($files);
} else {
return [];
}
diff --git a/lib/private/Preview/HEIC.php b/lib/private/Preview/HEIC.php
index 151326129bc..54bc212b6b5 100644
--- a/lib/private/Preview/HEIC.php
+++ b/lib/private/Preview/HEIC.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
@@ -22,19 +23,118 @@
namespace OC\Preview;
-class HEIC extends Bitmap {
+use OCP\ILogger;
+
+/**
+ * Creates a JPG preview using ImageMagick via the PECL extension
+ *
+ * @package OC\Preview
+ */
+class HEIC extends Provider {
/**
* {@inheritDoc}
*/
- public function getMimeType() {
+ public function getMimeType(): string {
return '/image\/hei(f|c)/';
}
/**
* {@inheritDoc}
*/
- public function isAvailable(\OCP\Files\FileInfo $file) {
- return in_array("HEIC", \Imagick::queryFonts("HEI*") );
+ public function isAvailable(\OCP\Files\FileInfo $file): bool {
+ return in_array('HEIC', \Imagick::queryFormats("HEI*"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ $tmpPath = $fileview->toTmpFile($path);
+ if (!$tmpPath) {
+ return false;
+ }
+
+ // Creates \Imagick object from the heic file
+ try {
+ $bp = $this->getResizedPreview($tmpPath, $maxX, $maxY);
+ $bp->setFormat('jpg');
+ } catch (\Exception $e) {
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'File: ' . $fileview->getAbsolutePath($path) . ' Imagick says:',
+ 'level' => ILogger::ERROR,
+ 'app' => 'core',
+ ]);
+ return false;
+ }
+
+ unlink($tmpPath);
+
+ //new bitmap image object
+ $image = new \OC_Image();
+ $image->loadFromData($bp);
+ //check if image object is valid
+ return $image->valid() ? $image : false;
+ }
+
+ /**
+ * Returns a preview of maxX times maxY dimensions in JPG format
+ *
+ * * The default resolution is already 72dpi, no need to change it for a bitmap output
+ * * It's possible to have proper colour conversion using profileimage().
+ * ICC profiles are here: http://www.color.org/srgbprofiles.xalter
+ * * It's possible to Gamma-correct an image via gammaImage()
+ *
+ * @param string $tmpPath the location of the file to convert
+ * @param int $maxX
+ * @param int $maxY
+ *
+ * @return \Imagick
+ */
+ private function getResizedPreview($tmpPath, $maxX, $maxY) {
+ $bp = new \Imagick();
+
+ // Layer 0 contains either the bitmap or a flat representation of all vector layers
+ $bp->readImage($tmpPath . '[0]');
+
+ $bp->setImageFormat('jpg');
+
+ $bp = $this->resize($bp, $maxX, $maxY);
+
+ return $bp;
+ }
+
+ /**
+ * Returns a resized \Imagick object
+ *
+ * If you want to know more on the various methods available to resize an
+ * image, check out this link : @link https://stackoverflow.com/questions/8517304/what-the-difference-of-sample-resample-scale-resize-adaptive-resize-thumbnail-im
+ *
+ * @param \Imagick $bp
+ * @param int $maxX
+ * @param int $maxY
+ *
+ * @return \Imagick
+ */
+ private function resize($bp, $maxX, $maxY) {
+ list($previewWidth, $previewHeight) = array_values($bp->getImageGeometry());
+
+ // We only need to resize a preview which doesn't fit in the maximum dimensions
+ if ($previewWidth > $maxX || $previewHeight > $maxY) {
+ // If we want a small image (thumbnail) let's be most space- and time-efficient
+ if ($maxX <= 500 && $maxY <= 500) {
+ $bp->thumbnailImage($maxY, $maxX, true);
+ $bp->stripImage();
+ } else {
+ // A bigger image calls for some better resizing algorithm
+ // According to http://www.imagemagick.org/Usage/filter/#lanczos
+ // the catrom filter is almost identical to Lanczos2, but according
+ // to http://php.net/manual/en/imagick.resizeimage.php it is
+ // significantly faster
+ $bp->resizeImage($maxX, $maxY, \Imagick::FILTER_CATROM, 1, true);
+ }
+ }
+
+ return $bp;
}
}
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 037ea53048a..9497b2c2637 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1208,6 +1208,10 @@ class Manager implements IManager {
* @throws ShareNotFound
*/
public function getShareByToken($token) {
+ // tokens can't be valid local user names
+ if ($this->userManager->userExists($token)) {
+ throw new ShareNotFound();
+ }
$share = null;
try {
if($this->shareApiAllowLinks()) {
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index ab52a68caeb..9c7e6001e5e 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -152,7 +152,7 @@ class OC_App {
\OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
try {
self::requireAppFile($app);
- } catch (Error $ex) {
+ } catch (Throwable $ex) {
\OC::$server->getLogger()->logException($ex);
if (!\OC::$server->getAppManager()->isShipped($app)) {
// Only disable apps which are not shipped