Skip to content

Commit

Permalink
Addon-Update optimieren (#5550)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Feb 4, 2023
1 parent 84809c4 commit 19d3a20
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions redaxo/src/addons/install/lib/package/package_update.php
Expand Up @@ -106,8 +106,26 @@ public function doAction()
}

// ---- update main addon dir
rex_dir::delete($path);
rename($temppath, $path);
$pathOld = rex_path::addon($this->addonkey.'.old');
error_clear_last();
// move current addon to temp path
if (!@rename($path, $pathOld)) {
$message = $path.' could not be moved to '.$pathOld;
$message .= ($error = error_get_last()) ? ': '.$error['message'] : '.';
throw new rex_functional_exception($message);
}
// move new addon to main addon path
if (@rename($temppath, $path)) {
// remove temp path of old addon
rex_dir::delete($pathOld);
} else {
// revert to old addon
rename($pathOld, $path);

$message = $temppath . ' could not be moved to '.$path;
$message .= ($error = error_get_last()) ? ': '.$error['message'] : '.';
throw new rex_functional_exception($message);
}

// ---- update assets
$origAssets = $this->addon->getPath('assets');
Expand Down

0 comments on commit 19d3a20

Please sign in to comment.