Use dedicated OC_Image loader methods

This prevents excessive logging and disk access
This commit is contained in:
Thomas Tanghus 2013-11-13 00:36:42 +01:00
parent dc30056025
commit ec51825d31
5 changed files with 12 additions and 7 deletions

View File

@ -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));
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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');

View File

@ -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;
}