Changeset 2101

Show
Ignore:
Timestamp:
03/14/08 04:08:14 (2 months ago)
Author:
anarcat
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/bureau/admin/bro_main.php

    r2094 r2101  
    113113if ($actextract) { 
    114114  print _("extracting..."); 
    115   if ($bro->ExtractFile($file, $R)) { 
     115  if ($bro->ExtractFile($R. '/' . $file, $R)) { 
    116116    print $err->errstr(); 
    117117    print _("failed"); 
  • alternc/trunk/bureau/class/m_bro.php

    r2092 r2101  
    424424  { 
    425425    global $err; 
    426     static $i=0, $ret; 
    427426    $file = $this->convertabsolute($file,0); 
    428427    if (is_null($dest)) { 
     
    437436    $file = escapeshellarg($file); 
    438437    $dest = escapeshellarg($dest); 
    439     if ($i == 0) { 
    440438#TODO new version of tar supports `tar xf ...` so there is no 
    441439#     need to specify the compression format 
    442       exec("tar -xzf '$file' -C '$dest'", $void, $ret); 
    443     } else if ($i == 1) { 
    444       exec("tar -xjf '$file' -C '$dest'", $void, $ret); 
    445     } else if ($i == 2) { 
    446       exec("unzip '$file' -d '$dest'", $void, $ret); 
    447     } else { 
    448       $err->raise("bro","undefined extractiong error: %s", $ret); 
    449       return $ret; 
    450     } 
    451  
     440    exec("tar -xzf $file -C $dest", $void, $ret); 
    452441    if ($ret) { 
    453       $i++; 
    454       $ret = $this->ExtractFile($file, $dest); 
    455       if ($ret) { 
    456         $err->raise("bro","could not find a way to extract file %s, unsupported format?", $file); 
    457       } 
    458     } 
     442      #print "tgz extraction failed, moving on to tbz\n"; 
     443      exec("tar -xjf $file -C $dest", $void, $ret); 
     444    } 
     445    if ($ret) { 
     446      $cmd = "unzip -o $file -d $dest"; 
     447      #print "tbz extraction failed, moving on to zip: $cmd\n"; 
     448      exec($cmd, $void, $ret); 
     449    } 
     450    if ($ret) { 
     451      $err->raise("bro","could not find a way to extract file %s, unsupported format?", $file); 
     452    } 
     453 
    459454    return $ret; 
    460455  }