Skip to content
Snippets Groups Projects
Commit d6a9af31 authored by Robin Appelman's avatar Robin Appelman
Browse files

add support for installing apps from tgz

parent 72882beb
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,7 @@ class OC_Installer{
//download the file if necesary
if($data['source']=='http'){
$path=OC_Helper::tmpFile('.zip');
$path=OC_Helper::tmpFile();
if(!isset($data['href'])){
OC_Log::write('core','No href specified when installing app from http',OC_Log::ERROR);
return false;
......@@ -76,14 +76,24 @@ class OC_Installer{
$path=$data['path'];
}
//detect the archive type
$mime=OC_Helper::getMimeType($path);
if($mime=='application/zip'){
rename($path,$path.'.zip');
$path.='.zip';
}elseif($mime=='application/x-gzip'){
rename($path,$path.'.tgz');
$path.='.tgz';
}else{
OC_Log::write('core','Archives of type '.$mime.' are not supported',OC_Log::ERROR);
return false;
}
//extract the archive in a temporary folder
$extractDir=tempnam(get_temp_dir(),'oc_installer_uncompressed_');
unlink($extractDir);
$extractDir=OC_Helper::tmpFolder();
mkdir($extractDir);
$zip = new ZipArchive;
if($zip->open($path)===true){
$zip->extractTo($extractDir);
$zip->close();
if($archive=OC_Archive::open($path)){
$archive->extract($extractDir);
} else {
OC_Log::write('core','Failed to open archive when installing app',OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment