movie previews: use file directly when it's stored locally and encryption is not enabled, fixes #7756
This commit is contained in:
parent
ecc41fe0c3
commit
7396e5f455
|
@ -41,6 +41,13 @@ if (!\OC_Util::runningOnWindows()) {
|
||||||
|
|
||||||
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
||||||
// TODO: use proc_open() and stream the source file ?
|
// TODO: use proc_open() and stream the source file ?
|
||||||
|
|
||||||
|
$fileInfo = $fileview->getFileInfo($path);
|
||||||
|
$useFileDirectly = (!$fileInfo->isEncrypted() && !$fileInfo->isMounted());
|
||||||
|
|
||||||
|
if ($useFileDirectly) {
|
||||||
|
$absPath = $fileview->getLocalFile($path);
|
||||||
|
} else {
|
||||||
$absPath = \OC_Helper::tmpFile();
|
$absPath = \OC_Helper::tmpFile();
|
||||||
|
|
||||||
$handle = $fileview->fopen($path, 'rb');
|
$handle = $fileview->fopen($path, 'rb');
|
||||||
|
@ -49,6 +56,7 @@ if (!\OC_Util::runningOnWindows()) {
|
||||||
// in some cases 1MB was no enough to generate thumbnail
|
// in some cases 1MB was no enough to generate thumbnail
|
||||||
$firstmb = stream_get_contents($handle, 5242880);
|
$firstmb = stream_get_contents($handle, 5242880);
|
||||||
file_put_contents($absPath, $firstmb);
|
file_put_contents($absPath, $firstmb);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->generateThumbNail($maxX, $maxY, $absPath, 5);
|
$result = $this->generateThumbNail($maxX, $maxY, $absPath, 5);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
@ -58,8 +66,9 @@ if (!\OC_Util::runningOnWindows()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$useFileDirectly) {
|
||||||
unlink($absPath);
|
unlink($absPath);
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue