Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-03-29 02:07:28 +0400
committerRobin Appelman <icewind@owncloud.com>2012-03-29 02:07:28 +0400
commitd6a9af31389819c95084e33aab3c7f4a6d4cbef8 (patch)
tree9c32a24fc899a66d2ecf5bc77739cd25affc0e50 /lib/installer.php
parent72882beb0d6ba7ebb70bdd6265c15656376e742c (diff)
add support for installing apps from tgz
Diffstat (limited to 'lib/installer.php')
-rw-r--r--lib/installer.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/installer.php b/lib/installer.php
index 2a9676998f6..db64d8e32d5 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -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);