public static void replaceDist(Path stagedDir, Path home, boolean asUndo, Map<String, Boolean> undoTasks, MessageWriter log) throws ProvisioningException {
log.verbose("Moving the provisioned installation from the staged directory to %s", home);
if (Files.exists(home)) {
if(asUndo) {
StateHistoryUtils.removeLastUndoConfig(home, stagedDir, log);
} else {
StateHistoryUtils.addNewUndoConfig(home, stagedDir, undoTasks, log);
}
IoUtils.recursiveDelete(home);
}
try {
IoUtils.copy(stagedDir, home);
} catch (IOException e) {
throw new ProvisioningException(Errors.copyFile(stagedDir, home));
}
}
}