continue;
}
$path = $this->_prependPath($props['installed_as'], $this->installroot);
- if (!@unlink($path)) {
- $this->log(2, "unable to delete: $path");
- } else {
- $this->log(2, "deleted file $path");
- // Delete package directory if it's empty
- if (@rmdir(dirname($path))) {
- $this->log(3, "+ rmdir $path");
- }
- }
+ $this->addFileOperation('delete', array($path));
}
return true;
}
// }}}
// {{{ startFileTransaction()
- function startFileTransaction($revert_in_case = false)
+ function startFileTransaction($rollback_in_case = false)
{
- if (count($this->file_operations) && $revert_in_case) {
- $this->revertFileTransaction();
+ if (count($this->file_operations) && $rollback_in_case) {
+ $this->rollbackFileTransaction();
}
$this->file_operations = array();
}
switch ($type) {
case 'rename':
@rename($data[0], $data[1]);
+ $this->log(3, "+ mv $data[0] $data[1]");
break;
case 'chmod':
@chmod($data[0], $data[1]);
+ $this->log(3, "+ chmod $data[0] $data[1]");
break;
case 'delete':
@unlink($data[0]);
+ $this->log(3, "+ rm $data[0]");
+ break;
+ case 'rmdir':
+ @rmdir($data[0]);
+ $this->log(3, "+ rmdir $data[0]");
break;
}
}
}
// }}}
- // {{{ revertFileTransaction()
+ // {{{ rollbackFileTransaction()
- function revertFileTransaction()
+ function rollbackFileTransaction()
{
$n = count($this->file_operations);
- $this->log(2, "reverting $n file operations");
+ $this->log(2, "rolling back $n file operations");
foreach ($this->file_operations as $tr) {
list($type, $data) = $tr;
switch ($type) {
function mkDirHier($dir)
{
- $this->addFileOperation('mkdir', $dir);
+ $this->addFileOperation('mkdir', array($dir));
return parent::mkDirHier($dir);
}
$this->popExpect();
if (PEAR::isError($res)) {
if (empty($options['force'])) {
- $this->revertFileTransaction();
+ $this->rollbackFileTransaction();
return $this->raiseError($res);
} else {
$this->log(0, "Warning: " . $res->getMessage());
$bob->debug = $this->debug;
$built = $bob->build($descfile, array(&$this, '_buildCallback'));
if (PEAR::isError($built)) {
- $this->revertFileTransaction();
+ $this->rollbackFileTransaction();
return $built;
}
foreach ($built as $ext) {
$this->log(3, "+ cp $ext[file] ext_dir");
$copyto = $this->_prependPath($dest, $this->installroot);
if (!@copy($ext['file'], $copyto)) {
- $this->revertFileTransaction();
+ $this->rollbackFileTransaction();
return $this->raiseError("failed to copy $bn to $copyto");
}
$pkginfo['filelist'][$bn] = array(
}
if (!$this->commitFileTransaction()) {
- $this->revertFileTransaction();
+ $this->rollbackFileTransaction();
return $this->raiseError("commit failed", PEAR_INSTALLER_FAILED);
}
// Delete the files
if (PEAR::isError($err = $this->_deletePackageFiles($package))) {
+ $this->rollbackFileTransaction();
return $this->raiseError($err);
}
+ if (!$this->commitFileTransaction()) {
+ $this->rollbackFileTransaction();
+ return $this->raiseError("uninstall failed");
+ }
// Register that the package is no longer installed
return $this->registry->deletePackage($package);