Source:
<code>protected void installFromFile() throws Exception { File installMarker = new File(installDirectory, ".installed"); if (!refresh) { if (!installMarker.exists()) { refresh = true; } else if (assemblyArchive.lastModified() > installMarker.lastModified()) { log.debug(MessageFormat.format(messages.getString("debug.detect.assembly.archive"), "")); refresh = true; } else if(!assemblyArchive.getCanonicalPath().equals(FileUtils.fileRead(installMarker))) { refresh = true; } } else { log.debug(MessageFormat.format(messages.getString("debug.request.refresh"), "")); } if (refresh && installDirectory.exists() && installDirectory.isDirectory()) { log.info(MessageFormat.format(messages.getString("info.uninstalling.server.home"), installDirectory)); for(File f : installDirectory.listFiles()) { <START> if(f.isDirectory() && f.getCanonicalPath().equals(userDirectory.getCanonicalPath())) <END> else { FileUtils.forceDelete(f); } } } if (!installMarker.exists()) { log.info("Installing assembly..."); FileUtils.forceMkdir(installDirectory); Expand unzip = (Expand) ant.createTask("unzip"); unzip.setSrc(assemblyArchive); unzip.setDest(assemblyInstallDirectory.getCanonicalFile()); unzip.execute(); Chmod chmod = (Chmod) ant.createTask("chmod"); chmod.setPerm("ugo+rx"); chmod.setDir(installDirectory); chmod.setIncludes("bin/*"); chmod.setExcludes("bin/*.bat"); chmod.execute(); installMarker.delete(); installMarker.createNewFile(); FileUtils.fileWrite(installMarker, assemblyArchive.getCanonicalPath()); } else { log.info(MessageFormat.format(messages.getString("info.reuse.installed.assembly"), "")); } }</code><technical_language>userDirectory is for loop, get canonical path store in variable for comparison in if statement. Also, empty if statement is odd. put a ! do FileUtils.forceDelete(f); if get rid of else</technical_language>

Target:
protected void installFromFile() throws Exception { File installMarker = new File(installDirectory, ".installed"); if (!refresh) { if (!installMarker.exists()) { refresh = true; } else if (assemblyArchive.lastModified() > installMarker.lastModified()) { log.debug(MessageFormat.format(messages.getString("debug.detect.assembly.archive"), "")); refresh = true; } else if(!assemblyArchive.getCanonicalPath().equals(FileUtils.fileRead(installMarker))) { refresh = true; } } else { log.debug(MessageFormat.format(messages.getString("debug.request.refresh"), "")); } String userDirectoryPath = userDirectory.getCanonicalPath(); if (refresh && installDirectory.exists() && installDirectory.isDirectory()) { log.info(MessageFormat.format(messages.getString("info.uninstalling.server.home"), installDirectory)); for(File f : installDirectory.listFiles()) { if(!(f.isDirectory() && f.getCanonicalPath().equals(userDirectoryPath))) { FileUtils.forceDelete(f); } } } if (!installMarker.exists()) { log.info("Installing assembly..."); FileUtils.forceMkdir(installDirectory); Expand unzip = (Expand) ant.createTask("unzip"); unzip.setSrc(assemblyArchive); unzip.setDest(assemblyInstallDirectory.getCanonicalFile()); unzip.execute(); Chmod chmod = (Chmod) ant.createTask("chmod"); chmod.setPerm("ugo+rx"); chmod.setDir(installDirectory); chmod.setIncludes("bin/*"); chmod.setExcludes("bin/*.bat"); chmod.execute(); installMarker.delete(); installMarker.createNewFile(); FileUtils.fileWrite(installMarker, assemblyArchive.getCanonicalPath()); } else { log.info(MessageFormat.format(messages.getString("info.reuse.installed.assembly"), "")); } }