append file extension to the temporary file which contains the downloaded archive - in case of zip files fileinfo doesn't seem to return anything reliable

This commit is contained in:
Thomas Müller 2014-07-11 16:51:59 +02:00
parent 8dc3c3ed6a
commit e47cd5ebf1
1 changed files with 4 additions and 9 deletions

View File

@ -235,9 +235,10 @@ class OC_Installer{
throw new \Exception($l->t("No source specified when installing app")); throw new \Exception($l->t("No source specified when installing app"));
} }
//download the file if necesary //download the file if necessary
if($data['source']=='http') { if($data['source']=='http') {
$path=OC_Helper::tmpFile(); $pathInfo = pathinfo($data['href']);
$path=OC_Helper::tmpFile('.' . $pathInfo['extension']);
if(!isset($data['href'])) { if(!isset($data['href'])) {
throw new \Exception($l->t("No href specified when installing app from http")); throw new \Exception($l->t("No href specified when installing app from http"));
} }
@ -251,13 +252,7 @@ class OC_Installer{
//detect the archive type //detect the archive type
$mime=OC_Helper::getMimeType($path); $mime=OC_Helper::getMimeType($path);
if($mime=='application/zip') { if ($mime !=='application/zip' && $mime !== 'application/x-gzip') {
rename($path, $path.'.zip');
$path.='.zip';
}elseif($mime=='application/x-gzip') {
rename($path, $path.'.tgz');
$path.='.tgz';
}else{
throw new \Exception($l->t("Archives of type %s are not supported", array($mime))); throw new \Exception($l->t("Archives of type %s are not supported", array($mime)));
} }