Update: Show restart button after an update is handled by a post-processor

This commit is contained in:
zzz
2021-08-02 11:36:38 -04:00
parent f2b878d02a
commit cf38697774
4 changed files with 30 additions and 4 deletions

View File

@@ -79,6 +79,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
private volatile ClientAppState _state = UNINITIALIZED;
private volatile String _status;
private volatile boolean _externalRestartPending;
private static final long DEFAULT_MAX_TIME = 3*60*60*1000L;
private static final long DEFAULT_CHECK_TIME = 60*1000;
@@ -565,6 +566,16 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
}
}
/**
* A router update had been downloaded and handled by an UpdatePostProcessor.
* It will provide wrapper-like function to install the update and restart after shutdown.
*
* @since 0.9.51
*/
public boolean isExternalRestartPending() {
return _externalRestartPending;
}
/**
* Install a plugin. Non-blocking.
* If returns true, then call isUpdateInProgress() in a loop
@@ -1376,10 +1387,12 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
(ftype == SU3File.TYPE_EXE && SystemVersion.isWindows())) {
Integer key = Integer.valueOf(updateType.toString().hashCode() ^ ftype);
UpdatePostProcessor upp = _registeredPostProcessors.get(key);
if (upp != null)
if (upp != null) {
upp.updateDownloadedandVerified(updateType, ftype, actualVersion, temp);
else
_externalRestartPending = true;
} else {
err = "Unsupported su3 file type " + ftype;
}
} else {
err = "Unsupported su3 file type " + ftype;
}

View File

@@ -69,6 +69,18 @@ public class NewsHelper extends ContentHelper {
mgr.getUpdateAvailable(ROUTER_SIGNED_SU3) != null;
}
/**
* A router update had been downloaded and handled by an UpdatePostProcessor.
* It will provide wrapper-like function to install the update and restart after shutdown.
*
* @since 0.9.51
*/
public static boolean isExternalRestartPending() {
ConsoleUpdateManager mgr = ConsoleUpdateManager.getInstance();
if (mgr == null) return false;
return mgr.isExternalRestartPending();
}
/**
* Release update only.
* Available version, will be null if already downloaded.

View File

@@ -6,6 +6,7 @@ import net.i2p.router.RouterContext;
import net.i2p.router.web.ConfigServiceHandler;
import net.i2p.router.web.ContextHelper;
import net.i2p.router.web.Messages;
import net.i2p.router.web.NewsHelper;
import net.i2p.util.RandomSource;
/**
@@ -92,7 +93,7 @@ public class ConfigRestartBean {
buf.append("</h4><hr>");
buttons(ctx, buf, urlBase, systemNonce, SET2);
} else {
if (ctx.hasWrapper())
if (ctx.hasWrapper() || NewsHelper.isExternalRestartPending())
buttons(ctx, buf, urlBase, systemNonce, SET3);
else
buttons(ctx, buf, urlBase, systemNonce, SET4);

View File

@@ -837,7 +837,7 @@ public class SummaryHelper extends HelperBase {
else
needSpace = true;
buf.append("<h4 class=\"sb_info sb_update\"><b>").append(_t("Update downloaded")).append("<br>");
if (_context.hasWrapper())
if (_context.hasWrapper() || NewsHelper.isExternalRestartPending())
buf.append(_t("Click Restart to install"));
else
buf.append(_t("Click Shutdown and restart to install"));