diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-06-14 01:01:59 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-06-14 01:01:59 +0200 |
commit | 35f7565e9b56b0550b5d79598d07fe69cb728e6a (patch) | |
tree | 997ef4620dc032fcde8346e0ad2fccdddd20b407 /lib | |
parent | 2b82e3c2511e8d7d20b6bf368cd78eb63e186681 (diff) | |
parent | 7396e5f455b0e723e9c7ef41bfb34a17de0569cf (diff) | |
download | nextcloud-server-35f7565e9b56b0550b5d79598d07fe69cb728e6a.tar.gz nextcloud-server-35f7565e9b56b0550b5d79598d07fe69cb728e6a.zip |
Merge pull request #8978 from owncloud/movie_preview_improvements
movie previews: use file directly when it's stored locally and encryption is not enabled
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/preview/movies.php | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/private/preview/movies.php b/lib/private/preview/movies.php index 72ccfadc6e9..2a23c2141c1 100644 --- a/lib/private/preview/movies.php +++ b/lib/private/preview/movies.php @@ -41,14 +41,22 @@ if (!\OC_Util::runningOnWindows()) { public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { // TODO: use proc_open() and stream the source file ? - $absPath = \OC_Helper::tmpFile(); - $handle = $fileview->fopen($path, 'rb'); + $fileInfo = $fileview->getFileInfo($path); + $useFileDirectly = (!$fileInfo->isEncrypted() && !$fileInfo->isMounted()); - // we better use 5MB (1024 * 1024 * 5 = 5242880) instead of 1MB. - // in some cases 1MB was no enough to generate thumbnail - $firstmb = stream_get_contents($handle, 5242880); - file_put_contents($absPath, $firstmb); + if ($useFileDirectly) { + $absPath = $fileview->getLocalFile($path); + } else { + $absPath = \OC_Helper::tmpFile(); + + $handle = $fileview->fopen($path, 'rb'); + + // we better use 5MB (1024 * 1024 * 5 = 5242880) instead of 1MB. + // in some cases 1MB was no enough to generate thumbnail + $firstmb = stream_get_contents($handle, 5242880); + file_put_contents($absPath, $firstmb); + } $result = $this->generateThumbNail($maxX, $maxY, $absPath, 5); if ($result === false) { @@ -58,8 +66,9 @@ if (!\OC_Util::runningOnWindows()) { } } - unlink($absPath); - + if (!$useFileDirectly) { + unlink($absPath); + } return $result; } |