I think that might be a working UpdatePostProcessor, now to figure out how to register it
This commit is contained in:
@ -13,7 +13,6 @@ import java.lang.InterruptedException;
|
||||
|
||||
public class WindowsUpdatePostProcessor {
|
||||
protected static Router i2pRouter = null;
|
||||
Process updateProcess = null;
|
||||
public void updateDownloadedandVerified(UpdateType type, int fileType, String version, File file) throws IOException {
|
||||
if (fileType == 6) {
|
||||
if (runUpdate(file)) {
|
||||
@ -23,32 +22,35 @@ public class WindowsUpdatePostProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean runUpdate(File file){
|
||||
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", file.getAbsolutePath());
|
||||
try {
|
||||
updateProcess = pb.start();
|
||||
} catch (IOException ex) {
|
||||
// At this point a failure is harmless, but it's also not at all important to
|
||||
// restart the router. Return false.
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
updateProcess.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
// if the NSIS installer process got interrupted here, it's possible that the
|
||||
// install was left in a broken state. I think we should direct the uses to
|
||||
// re-run the installer if this happens. TODO: java dialog boxes. That should be
|
||||
// easy.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
Process updateProcess = null;
|
||||
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", file.getAbsolutePath());
|
||||
try {
|
||||
updateProcess = pb.start();
|
||||
} catch (IOException ex) {
|
||||
// At this point a failure is harmless, but it's also not at all important to
|
||||
// restart the router. Return false.
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
updateProcess.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
// if the NSIS installer process got interrupted here, it's possible that the
|
||||
// install was left in a broken state. I think we should direct the uses to
|
||||
// re-run the installer if this happens. TODO: java dialog boxes. That should be
|
||||
// easy.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean shutdownGracefullyAndRerun() {
|
||||
i2pRouter.shutdownGracefully();
|
||||
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", selectProgramFile().getAbsolutePath());
|
||||
while (i2pRouter.gracefulShutdownInProgress()){
|
||||
}
|
||||
if (i2pRouter.isFinalShutdownInProgress()){
|
||||
if (i2pRouter.isFinalShutdownInProgress()) {
|
||||
try {
|
||||
Process restartProcess = pb.start();
|
||||
} catch (IOException ex) {
|
||||
@ -72,4 +74,15 @@ public class WindowsUpdatePostProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
protected static File selectProgramFileExe() {
|
||||
File pfpath = selectProgramFile();
|
||||
if (SystemVersion.isWindows()) {
|
||||
File app = new File(pfpath, "I2P.exe");
|
||||
return app.getAbsoluteFile();
|
||||
} else {
|
||||
File app = new File(pfpath, "bin/I2P");
|
||||
return app.getAbsoluteFile();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user