From ec51825d318ebc28069e1bf55fe51105d2ec1a0c Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Wed, 13 Nov 2013 00:36:42 +0100 Subject: [PATCH] Use dedicated OC_Image loader methods This prevents excessive logging and disk access --- lib/private/preview/image.php | 4 ++-- lib/private/preview/movies.php | 3 ++- lib/private/preview/mp3.php | 6 ++++-- lib/private/preview/office-cl.php | 3 ++- lib/private/preview/office-fallback.php | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/private/preview/image.php b/lib/private/preview/image.php index 9aec967282d..84343df2608 100644 --- a/lib/private/preview/image.php +++ b/lib/private/preview/image.php @@ -21,11 +21,11 @@ class Image extends Provider { return false; } + $image = new \OC_Image(); //check if file is encrypted if($fileInfo['encrypted'] === true) { - $image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r'))); + $image->loadFromData(stream_get_contents($fileview->fopen($path, 'r'))); }else{ - $image = new \OC_Image(); $image->loadFromFile($fileview->getLocalFile($path)); } diff --git a/lib/private/preview/movies.php b/lib/private/preview/movies.php index 4d85e23c63c..1802a20711e 100644 --- a/lib/private/preview/movies.php +++ b/lib/private/preview/movies.php @@ -36,7 +36,8 @@ if (!\OC_Util::runningOnWindows()) { shell_exec($cmd); - $image = new \OC_Image($tmpPath); + $image = new \OC_Image(); + $image->loadFromFile($tmpPath); unlink($absPath); unlink($tmpPath); diff --git a/lib/private/preview/mp3.php b/lib/private/preview/mp3.php index 1eed566315c..3fc0ab0490c 100644 --- a/lib/private/preview/mp3.php +++ b/lib/private/preview/mp3.php @@ -25,7 +25,8 @@ class MP3 extends Provider { if(isset($tags['id3v2']['APIC'][0]['data'])) { $picture = @$tags['id3v2']['APIC'][0]['data']; unlink($tmpPath); - $image = new \OC_Image($picture); + $image = new \OC_Image(); + $image->loadFromData($picture); return $image->valid() ? $image : $this->getNoCoverThumbnail(); } @@ -39,7 +40,8 @@ class MP3 extends Provider { return false; } - $image = new \OC_Image($icon); + $image = new \OC_Image(); + $image->loadFromFile($icon); return $image->valid() ? $image : false; } diff --git a/lib/private/preview/office-cl.php b/lib/private/preview/office-cl.php index 8f2e06c050b..b11fed13ba1 100644 --- a/lib/private/preview/office-cl.php +++ b/lib/private/preview/office-cl.php @@ -48,7 +48,8 @@ if (!\OC_Util::runningOnWindows()) { return false; } - $image = new \OC_Image($pdf); + $image = new \OC_Image(); + $image->loadFromData($pdf); unlink($absPath); unlink($absPath . '.pdf'); diff --git a/lib/private/preview/office-fallback.php b/lib/private/preview/office-fallback.php index e69ab0ab8cb..f184b3149d5 100644 --- a/lib/private/preview/office-fallback.php +++ b/lib/private/preview/office-fallback.php @@ -80,7 +80,8 @@ class MSOfficeExcel extends Provider { unlink($absPath); unlink($tmpPath); - $image = new \OC_Image($pdf); + $image = new \OC_Image(); + $image->loadFromData($pdf); return $image->valid() ? $image : false; } -- 2.39.5