fix archive extraction:
* call with the proper path * remove the quotes from the calls, they're already there * make ExtractFile non-recursive * force unzip extraction to overwrite existing files
This commit is contained in:
parent
7269275e5c
commit
c192607d51
|
@ -112,7 +112,7 @@ if ($formu) {
|
||||||
|
|
||||||
if ($actextract) {
|
if ($actextract) {
|
||||||
print _("extracting...");
|
print _("extracting...");
|
||||||
if ($bro->ExtractFile($file, $R)) {
|
if ($bro->ExtractFile($R. '/' . $file, $R)) {
|
||||||
print $err->errstr();
|
print $err->errstr();
|
||||||
print _("failed");
|
print _("failed");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -423,7 +423,6 @@ class m_bro {
|
||||||
function ExtractFile($file, $dest=null)
|
function ExtractFile($file, $dest=null)
|
||||||
{
|
{
|
||||||
global $err;
|
global $err;
|
||||||
static $i=0, $ret;
|
|
||||||
$file = $this->convertabsolute($file,0);
|
$file = $this->convertabsolute($file,0);
|
||||||
if (is_null($dest)) {
|
if (is_null($dest)) {
|
||||||
$dest = dirname($file);
|
$dest = dirname($file);
|
||||||
|
@ -436,26 +435,22 @@ class m_bro {
|
||||||
}
|
}
|
||||||
$file = escapeshellarg($file);
|
$file = escapeshellarg($file);
|
||||||
$dest = escapeshellarg($dest);
|
$dest = escapeshellarg($dest);
|
||||||
if ($i == 0) {
|
|
||||||
#TODO new version of tar supports `tar xf ...` so there is no
|
#TODO new version of tar supports `tar xf ...` so there is no
|
||||||
# need to specify the compression format
|
# need to specify the compression format
|
||||||
exec("tar -xzf '$file' -C '$dest'", $void, $ret);
|
exec("tar -xzf $file -C $dest", $void, $ret);
|
||||||
} else if ($i == 1) {
|
|
||||||
exec("tar -xjf '$file' -C '$dest'", $void, $ret);
|
|
||||||
} else if ($i == 2) {
|
|
||||||
exec("unzip '$file' -d '$dest'", $void, $ret);
|
|
||||||
} else {
|
|
||||||
$err->raise("bro","undefined extractiong error: %s", $ret);
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
$i++;
|
#print "tgz extraction failed, moving on to tbz\n";
|
||||||
$ret = $this->ExtractFile($file, $dest);
|
exec("tar -xjf $file -C $dest", $void, $ret);
|
||||||
|
}
|
||||||
|
if ($ret) {
|
||||||
|
$cmd = "unzip -o $file -d $dest";
|
||||||
|
#print "tbz extraction failed, moving on to zip: $cmd\n";
|
||||||
|
exec($cmd, $void, $ret);
|
||||||
|
}
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
$err->raise("bro","could not find a way to extract file %s, unsupported format?", $file);
|
$err->raise("bro","could not find a way to extract file %s, unsupported format?", $file);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue