java.lang.Object
net.i2p.router.update.ConsoleUpdateManager
- All Implemented Interfaces:
ClientApp, RouterApp, UpdateManager
The central resource coordinating updates. This must be registered with the context.
The UpdateManager starts and stops all updates, prevents multiple updates as appropriate, and controls notification to the user.
Version notes: For news and unsigned updates, use Long.toString(long, int)modtime).
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classEquals on checker, type and method only.(package private) static classEquals on updater, type and method only.private classTimer clearing an old update status message.private classPeriodically drops checkers and downloaders whose tasks stopped running.(package private) static classEquals on type and ID only.(package private) static classThe version string of an installed or downloaded update, ordered numerically or by date against other versions.(package private) static classAn update that exists upstream, with its download sources per method and an optional reason it cannot currently be fetched.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Collection<UpdateTask> Active checking tasks.private final booleanTrue if torrent updates are allowed.private final ConcurrentHashMap<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.VersionAvailable> As reported by checkers.private final ClientAppManagerThe app manager used for restarts.private final RouterContextThe router context.private final Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.Version> Downloaded but NOT installed.private final Map<UpdateTask, List<ConsoleUpdateManager.RegisteredUpdater>> Active updating tasks, pointing to the next ones to try.private booleanTrue while an external restart is pending.private final Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.Version> Downloaded AND installed.private final LogLogger for the console updates.private static final DecimalFormatFormatter for the percentage display.private final Collection<ConsoleUpdateManager.RegisteredChecker> The registered checkers that look for new updates.private final Map<Integer, UpdatePostProcessor> Post-processors, by update type.private final Collection<ConsoleUpdateManager.RegisteredUpdater> The registered updaters that perform the downloads.private ClientAppStateCurrent state of the update manager app.private StringStatus message shown in the console, null if none.private static final longDefault delay before the first update check.private static final booleanDefault setting for torrent updates.private static final longDefault maximum time for one update attempt.private static final PatternMatches the detail of a verification failure message.private static final StringConfig key enabling dev SU3 updates.private static final StringConfig key enabling torrent updates.private static final StringConfig key enabling unsigned updates.private static final longTime an update status message stays shown.private static final longInterval between stale task cleanups.Fields inherited from interface UpdateManager
APP_NAMEConstructor Summary
ConstructorsConstructorDescriptionConsoleUpdateManager(RouterContext ctx, ClientAppManager listener, String[] args) Creates the manager; the update handlers for the router, plugins, news and the desktop GUI are registered and checks scheduled instartup().Method Summary
Modifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter.Translate a string with parameters.buildItemRows(Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.Version> installed, Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.Version> downloaded, Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.VersionAvailable> available, Map<UpdateType, Set<UpdateMethod>> checkMethods) Merge the installed, downloaded and available maps into one row set of {status, type, name, installed, available, methods}, sorted by name.(package private) static StringbuildUpdateTable(List<String[]> items, List<String[]> workers) Build the two-section table from the rows of buildItemRows {status, type, name, installed, available, methods} and buildWorkerRows {active, role, class, type, method, version}.buildWorkerRows(Collection<ConsoleUpdateManager.RegisteredChecker> checkers, Collection<ConsoleUpdateManager.RegisteredUpdater> updaters, Map<Integer, UpdatePostProcessor> postProcessors, Collection<UpdateTask> activeCheckers, Map<UpdateTask, List<ConsoleUpdateManager.RegisteredUpdater>> downloaders, Map<UpdateType, String> typeVersions) Merge the registered checkers, updaters and post-processors into one row set of {active, role, class, type, method, version}, sorted by role then class.private static Stringcapitalize(String s) Upper-case the first character, leaving the rest as-is.private voidchangeState(ClientAppState state) Record the app state and notify the client app manager of the change.voidcheck(UpdateType type) Fire off a checker task Non-blocking.voidcheck(UpdateType type, String id) Fire off a checker task Non-blocking.checkAvailable(UpdateType type) Is an update available? Blocking.checkAvailable(UpdateType type, long maxWait) Is an update available? Blocking.checkAvailable(UpdateType type, String id, long maxWait) Is an update available? Blocking.(package private) static StringMap an item or worker status to its status dot colour: green for installed or active, yellow for an available update, blue for a downloaded update awaiting install, grey otherwise.private voidfinishStatus(String msg) Shows the final status message and schedules its cleanup.(package private) static StringfmtVersion(String versionStr) Format a 13-digit version string as a date, otherwise as-is.int[]Debug overview counts as {installed, downloaded, available}, where available counts items with an update available from any source, including the internal placeholder.Name shown in the console plugin list.private StringgetDownloadedOrInstalledVersion(UpdateType type, String id) The highest of the installed or downloaded version.static ConsoleUpdateManagerFinds the registered console update manager app.getName()Application name.getState()Current state of the updater.The status on any update current or last finished.getUpdateAvailable(UpdateType type) Is an update available? Non-blocking, returns result of last check or notification from an Updater.getUpdateAvailable(UpdateType type, String id) Is an update available? Non-blocking, returns result of last check or notification from an Updater.getUpdateConstraint(UpdateType type, String id) Is there a reason we can't download the update?Is an update downloaded? Non-blocking, returns result of last download.getUpdateDownloaded(UpdateType type, String id) Is an update downloaded? Non-blocking, returns result of last download.getUpdateURLs(UpdateType type, String id, UpdateMethod method) Where to find various resources.private booleanhandleRouterFile(URI uri, String actualVersion, File f, UpdateType updateType) Process sud, su2, or su3.private booleanhandleUnsignedFile(URI uri, String lastmod, File updFile) Only for router updates.booleaninstallPlugin(String name, URI uri) Install a plugin.booleanIs any check in progress? Does not include updates.booleanisCheckInProgress(UpdateType type) Is a check in progress?booleanisCheckInProgress(UpdateType type, String id) Is a check in progress?booleanA router update had been downloaded and handled by an UpdatePostProcessor.booleanIs any download in progress? Does not include checks.booleanisUpdateInProgress(UpdateType type) Is a download in progress?booleanisUpdateInProgress(UpdateType type, String id) Is a download in progress?(package private) static StringitemDisplayName(UpdateType type, String id) Display name for an update item.(package private) static StringConvert a URL to an HTML clickable link.voidnotifyAttemptFailed(UpdateTask task, String reason, Throwable t) Not necessarily the end if there are more URIs to try.voidnotifyCheckComplete(UpdateTask task, boolean newer, boolean success) Called by the Updater after check() was called and allnotifyVersionAvailable(UpdateTask, URI, UpdateType, String, UpdateMethod, List, String, String)callbacks are finished.voidnotifyComplete(UpdateTask task, String status) An expiring status.booleannotifyComplete(UpdateTask task, String actualVersion, File file) An update has been downloaded but not verified.private voidnotifyDownloaded(UpdateType type, String id, String version) Adds to downloaded, removes from available.voidnotifyInstalled(UpdateType type, String id, String version) Adds to installed, removes from downloaded and available.voidnotifyProgress(UpdateTask task, String status) May be null.voidnotifyProgress(UpdateTask task, String status, long downloaded, long totalSize) Publish the download status text and progress bar to the console.voidnotifyTaskFailed(UpdateTask task, String reason, Throwable t) The task has finished and failed.booleannotifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, Map<UpdateMethod, List<URI>> sourceMap, String newVersion, String minVersion) Called by the Checker, either after check() was called, or it found out on its own.booleannotifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, UpdateMethod method, List<URI> updateSources, String newVersion, String minVersion) Called by the Updater, either aftercheck(UpdateType)was called, or it found out on its own.voidnotifyVersionConstraint(UpdateTask task, URI newsSource, UpdateType type, String id, String newVersion, String message) A new version is available but cannot be downloaded or installed due to some constraint.voidregister(Checker updater, UpdateType type, UpdateMethod method, int priority) Add the Checker to the set consulted for each update type and method.voidregister(UpdatePostProcessor upp, UpdateType type, int fileType) Register a post-processor for this UpdateType and SU3File file type.voidregister(Updater updater, UpdateType type, UpdateMethod method, int priority) Add the Updater to the set consulted for each update type and method.voidrenderStatusHTML(Writer out) Render update manager status HTML for the debug page as one table with two sections - update items, then registered checkers, updaters and post-processors - sharing a column grid so the content aligns.private voidrestart()Restarts the router console.private UpdateTaskretry(ConsoleUpdateManager.UpdateItem ui, Map<UpdateMethod, List<URI>> sourceMap, List<ConsoleUpdateManager.RegisteredUpdater> toTry, long maxTime) Schedules a retry of a failed update.(package private) booleanFrom NewsFetcher.voidshutdown()UpdateManager interface.voidClientApp interface.voidstart()UpdateManager interface.voidstartup()ClientApp interface.voidstopCheck(UpdateType type) Stop this check.voidstopCheck(UpdateType type, String id) Stop this check.voidStop all checks in progress.voidstopUpdate(UpdateType type) Stop this download.voidstopUpdate(UpdateType type, String id) Stop this download.voidStop all downloads in progress.voidunregister(Checker updater, UpdateType type, UpdateMethod method) Remove the Checker previously registered for the type and method.voidunregister(Updater updater, UpdateType type, UpdateMethod method) Remove the Updater previously registered for the type and method.booleanupdate(UpdateType type) Non-blocking.booleanupdate(UpdateType type, long maxTime) Non-blocking.booleanupdate(UpdateType type, String id) Non-blocking.booleanupdate(UpdateType type, String id, long maxTime) Non-blocking.private booleanupdate_fromCheck(UpdateType type, String id, long maxTime) Non-blocking.private voidSets the status message shown in the console.private static StringversionFor(Map<UpdateType, String> typeVersions, UpdateType type) The installed version string registered for a worker's type, or a dash when that type has no installed version.
Field Details
_context
The router context._log
Logger for the console updates._registeredUpdaters
The registered updaters that perform the downloads._registeredCheckers
The registered checkers that look for new updates._registeredPostProcessors
Post-processors, by update type._activeCheckers
Active checking tasks._downloaders
Active updating tasks, pointing to the next ones to try._available
private final ConcurrentHashMap<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.VersionAvailable> _availableAs reported by checkers._downloaded
Downloaded but NOT installed._installed
Downloaded AND installed._allowTorrent
private final boolean _allowTorrentTrue if torrent updates are allowed._pct
Formatter for the percentage display._cmgr
The app manager used for restarts._state
Current state of the update manager app._status
Status message shown in the console, null if none._externalRestartPending
private volatile boolean _externalRestartPendingTrue while an external restart is pending.DEFAULT_MAX_TIME
private static final long DEFAULT_MAX_TIMEDefault maximum time for one update attempt.- See Also:
DEFAULT_CHECK_TIME
private static final long DEFAULT_CHECK_TIMEDefault delay before the first update check.- See Also:
STATUS_CLEAN_TIME
private static final long STATUS_CLEAN_TIMETime an update status message stays shown.- See Also:
TASK_CLEANER_TIME
private static final long TASK_CLEANER_TIMEInterval between stale task cleanups.- See Also:
PROP_UNSIGNED_AVAILABLE
Config key enabling unsigned updates.- See Also:
PROP_DEV_SU3_AVAILABLE
Config key enabling dev SU3 updates.- See Also:
PROP_ENABLE_TORRENT_UPDATES
Config key enabling torrent updates.- See Also:
FOR_CONTENT_PATTERN
Matches the detail of a verification failure message.DEFAULT_ENABLE_TORRENT_UPDATES
private static final boolean DEFAULT_ENABLE_TORRENT_UPDATESDefault setting for torrent updates.- See Also:
Constructor Details
ConsoleUpdateManager
Creates the manager; the update handlers for the router, plugins, news and the desktop GUI are registered and checks scheduled instartup().- Parameters:
ctx- router context supplying the update policy, timers and logginglistener- client app manager to register this with and to notify of state changesargs- command line arguments, unused
Method Details
getInstance
Finds the registered console update manager app.- Returns:
- the running instance, null if the app is not registered
start
startup
shutdown
shutdown
getState
Current state of the updater.getName
getDisplayName
Name shown in the console plugin list.- Specified by:
getDisplayNamein interfaceClientApp- Returns:
- the human-readable plugin name
changeState
Record the app state and notify the client app manager of the change.- Parameters:
state- the new state of this client app
getStatus
The status on any update current or last finished.- Specified by:
getStatusin interfaceUpdateManager- Returns:
- status or ""
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Specified by:
checkAvailablein interfaceUpdateManager- Parameters:
type- the UpdateType of this request- Returns:
- new version or null if nothing newer is available
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Specified by:
checkAvailablein interfaceUpdateManager- Parameters:
type- the UpdateType of this requestmaxWait- max time to block- Returns:
- new version or null if nothing newer is available
checkAvailable
Is an update available? Blocking. An available update may still have a constraint or lack sources.- Specified by:
checkAvailablein interfaceUpdateManager- Parameters:
type- the UpdateType of this requestid- id of this requestmaxWait- max time to block- Returns:
- new version or null if nothing newer is available
check
Fire off a checker task Non-blocking.- Parameters:
type- the UpdateType of this request
check
Fire off a checker task Non-blocking.- Parameters:
type- the UpdateType of this requestid- id of this request
getUpdateAvailable
Is an update available? Non-blocking, returns result of last check or notification from an Updater. An available update may still have a constraint or lack sources.- Parameters:
type- the UpdateType of this request- Returns:
- new version or null if nothing newer is available
getUpdateAvailable
Is an update available? Non-blocking, returns result of last check or notification from an Updater. An available update may still have a constraint or lack sources.- Parameters:
type- the UpdateType of this requestid- id of this request- Returns:
- new version or null if nothing newer is available
getUpdateDownloaded
Is an update downloaded? Non-blocking, returns result of last download.- Parameters:
type- the UpdateType of this request- Returns:
- new version or null if nothing was downloaded
getUpdateDownloaded
Is an update downloaded? Non-blocking, returns result of last download.- Parameters:
type- the UpdateType of this requestid- id of this request- Returns:
- new version or null if nothing was downloaded
getDownloadedOrInstalledVersion
The highest of the installed or downloaded version.- Parameters:
type- the UpdateType to look upid- id of the request to look up- Returns:
- new version or null if nothing was downloaded or installed
isUpdateInProgress
public boolean isUpdateInProgress()Is any download in progress? Does not include checks.- Specified by:
isUpdateInProgressin interfaceUpdateManager- Returns:
- whether update in progress
isUpdateInProgress
Is a download in progress?- Specified by:
isUpdateInProgressin interfaceUpdateManager- Parameters:
type- the UpdateType of this request- Returns:
- whether update in progress
isUpdateInProgress
Is a download in progress?- Specified by:
isUpdateInProgressin interfaceUpdateManager- Parameters:
type- the UpdateType of this requestid- of this request- Returns:
- whether update in progress
stopUpdates
public void stopUpdates()Stop all downloads in progress.stopUpdate
Stop this download.- Parameters:
type- the UpdateType of this download
stopUpdate
Stop this download.- Parameters:
type- the UpdateType of this downloadid- id of this download
isCheckInProgress
public boolean isCheckInProgress()Is any check in progress? Does not include updates.- Returns:
- whether check in progress
isCheckInProgress
Is a check in progress?- Parameters:
type- the UpdateType of this request- Returns:
- whether check in progress
isCheckInProgress
Is a check in progress?- Parameters:
type- the UpdateType of this requestid- id of this request- Returns:
- whether check in progress
stopChecks
public void stopChecks()Stop all checks in progress.stopCheck
Stop this check.- Parameters:
type- the UpdateType of this check
stopCheck
Stop this check.- Parameters:
type- the UpdateType of this checkid- id of this check
isExternalRestartPending
public boolean isExternalRestartPending()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.- Returns:
- whether external restart pending
installPlugin
Install a plugin. Non-blocking. If returns true, then callisUpdateInProgress()in a loop.- Parameters:
name- if null, a new installuri- where to fetch the plugin, a file: URI installs without a network fetch- Returns:
- true if task started
update
Non-blocking. Does not check. If returns true, then call isUpdateInProgress() in a loop Max time 3 hours by default but not honored by all Updaters.- Specified by:
updatein interfaceUpdateManager- Parameters:
type- the UpdateType of this request- Returns:
- true if task started
update
Non-blocking. Does not check. Max time 3 hours by default but not honored by all Updaters If returns true, then call isUpdateInProgress() in a loop.- Specified by:
updatein interfaceUpdateManager- Parameters:
type- the UpdateType of this requestid- id of this request- Returns:
- true if task started
update
Non-blocking. Does not check. If returns true, then call isUpdateInProgress() in a loop.- Specified by:
updatein interfaceUpdateManager- Parameters:
type- the UpdateType of this requestmaxTime- not honored by all Updaters- Returns:
- true if task started
update
Non-blocking. Does not check. Fails if check or update already in progress. If returns true, then call isUpdateInProgress() in a loop.- Specified by:
updatein interfaceUpdateManager- Parameters:
type- the UpdateType of this requestid- id of this requestmaxTime- not honored by all Updaters- Returns:
- true if task started
update_fromCheck
Non-blocking. Does not check. Fails update already in progress. Use this to call from within a checker task. If returns true, then call isUpdateInProgress() in a loop.- Parameters:
type- the UpdateType to updateid- id of the request to updatemaxTime- not honored by all Updaters- Returns:
- true if task started
retry
private UpdateTask retry(ConsoleUpdateManager.UpdateItem ui, Map<UpdateMethod, List<URI>> sourceMap, List<ConsoleUpdateManager.RegisteredUpdater> toTry, long maxTime) Schedules a retry of a failed update.- Parameters:
ui- the update item to retrysourceMap- the source URIs, by methodtoTry- the updaters still to trymaxTime- the maximum time for the whole update- Returns:
- the scheduled task, null if none could be scheduled
register
Add the Updater to the set consulted for each update type and method.- Specified by:
registerin interfaceUpdateManager- Parameters:
updater- the Updater to be told when a newer version appearstype- the update typemethod- the update methodpriority- higher values are notified first
unregister
Remove the Updater previously registered for the type and method.- Specified by:
unregisterin interfaceUpdateManager- Parameters:
updater- the Updater to stop notifyingtype- the update typemethod- the update method
register
Add the Checker to the set consulted for each update type and method.- Specified by:
registerin interfaceUpdateManager- Parameters:
updater- the Checker to poll for a newer versiontype- the update typemethod- the update methodpriority- higher values are polled first
unregister
Remove the Checker previously registered for the type and method.- Specified by:
unregisterin interfaceUpdateManager- Parameters:
updater- the Checker to stop pollingtype- the update typemethod- the update method
register
Register a post-processor for this UpdateType and SU3File file type.- Specified by:
registerin interfaceUpdateManager- Parameters:
upp- update post processortype- only ROUTER_SIGNED_SU3 and ROUTER_DEV_SU3 are currently supportedfileType- a SU3File TYPE_xxx constant, 1-255, TYPE_ZIP not supported.
notifyVersionAvailable
public boolean notifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, UpdateMethod method, List<URI> updateSources, String newVersion, String minVersion) Called by the Updater, either aftercheck(UpdateType)was called, or it found out on its own. Use this if there is only one UpdateMethod; otherwise use the Map method below.- Specified by:
notifyVersionAvailablein interfaceUpdateManager- Parameters:
task- the running check or download this report concernsnewsSource- who told ustype- the UpdateType selecting which update is being reported onid- plugin name for plugins, ignored otherwisemethod- How to get the new versionupdateSources- Where to get the new versionnewVersion- The new version availableminVersion- The minimum installed version to be able to update to newVersion- Returns:
- true if it's newer
notifyVersionAvailable
public boolean notifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, Map<UpdateMethod, List<URI>> sourceMap, String newVersion, String minVersion) Called by the Checker, either after check() was called, or it found out on its own. Checkers must use this method if there are multiple UpdateMethods discovered simultaneously.- Specified by:
notifyVersionAvailablein interfaceUpdateManager- Parameters:
task- the running check or download this report concernsnewsSource- who told ustype- the UpdateType selecting which update is being reported onid- plugin name for plugins, ignored otherwisesourceMap- Mapping of methods to sourcesnewVersion- The new version availableminVersion- The minimum installed version to be able to update to newVersion- Returns:
- true if we didn't know already
notifyVersionConstraint
public void notifyVersionConstraint(UpdateTask task, URI newsSource, UpdateType type, String id, String newVersion, String message) A new version is available but cannot be downloaded or installed due to some constraint. The manager should notify the user. Called by the Checker, either after check() was called, or it found out on its own.- Specified by:
notifyVersionConstraintin interfaceUpdateManager- Parameters:
task- the running check or download this report concernsnewsSource- who told ustype- the UpdateType selecting which update is being reported onid- plugin name for plugins, ignored otherwisenewVersion- The new version availablemessage- A translated message to be displayed to the user, non-null
notifyCheckComplete
Called by the Updater after check() was called and allnotifyVersionAvailable(UpdateTask, URI, UpdateType, String, UpdateMethod, List, String, String)callbacks are finished.- Specified by:
notifyCheckCompletein interfaceUpdateManager- Parameters:
task- the running check or download this report concernsnewer- notifyVersionAvailable was calledsuccess- check succeeded (newer or not)
notifyProgress
Publish the download status text and progress bar to the console.- Specified by:
notifyProgressin interfaceUpdateManager- Parameters:
task- the running check or download this report concernsstatus- translated message to show to the user, may contain HTMLdownloaded- bytes received so far, for the progress bartotalSize- expected total bytes, for the progress bar
notifyProgress
May be null.- Specified by:
notifyProgressin interfaceUpdateManager- Parameters:
task- may be nullstatus- translated message to show to the user, may contain HTML
notifyComplete
An expiring status.- Parameters:
task- may be nullstatus- the message to show, cleared when it expires
notifyAttemptFailed
Not necessarily the end if there are more URIs to try.- Specified by:
notifyAttemptFailedin interfaceUpdateManager- Parameters:
task- checker or updaterreason- a short translated description of what went wrongt- may be null
notifyTaskFailed
The task has finished and failed.- Specified by:
notifyTaskFailedin interfaceUpdateManager- Parameters:
task- checker or updaterreason- a short translated description of what went wrongt- may be null
notifyComplete
An update has been downloaded but not verified. The manager will verify it. Caller should delete the file upon return, unless it will share it with others, e.g. on a torrent. If the return value is false, caller must callnotifyTaskFailed(UpdateTask, String, Throwable)or notifyComplete() again.- Specified by:
notifyCompletein interfaceUpdateManager- Parameters:
task- must be an Updater, not a CheckeractualVersion- may be higher (or lower?) than the version requestedfile- a valid format for the task's UpdateType, or null if it did the installation itself- Returns:
- true if valid, false if corrupt
notifyInstalled
Adds to installed, removes from downloaded and available.- Specified by:
notifyInstalledin interfaceUpdateManager- Parameters:
type- the UpdateType whose installed version is being recorded or clearedid- subtype for plugins, or ""version- null to remove from installed
notifyDownloaded
Adds to downloaded, removes from available.- Parameters:
type- the UpdateType that was downloadedid- id of the downloaded itemversion- the version string that was downloaded
shouldInstall
boolean shouldInstall()From NewsFetcher.- Returns:
- false if the update policy is notify-only or news has suppressed installs, or a downloaded router update zip is still pending
getUpdateURLs
Where to find various resources.- Parameters:
type- the UpdateType of this requestid- id of this requestmethod- the transport to list sources for- Returns:
- non-null may be empty
getUpdateConstraint
Is there a reason we can't download the update?- Parameters:
type- the UpdateType of this requestid- id of this request- Returns:
- translated constraint or null
handleRouterFile
Process sud, su2, or su3. Only for router updates.- Parameters:
uri- the download source, recorded in the update statusactualVersion- the version string reported by the downloadf- the downloaded file to verify and stageupdateType- router update type selecting the verification path- Returns:
- true if the file verified and was staged for install at next restart, false if verification or the copy failed
handleUnsignedFile
Only for router updates.- Parameters:
uri- download URI, used only for the status text and to tell an I2P+ (skank) build from a stock onelastmod- server-supplied last-modified timestamp in ms, as a string; the current time is used when null or unparseableupdFile- the downloaded file, verified as a zip and then copied into the router directory- Returns:
- true if the verified file was copied for install at next restart
restart
private void restart()Restarts the router console.linkify
_t
_t
_t
updateStatus
Sets the status message shown in the console.- Parameters:
s- the message to show
finishStatus
Shows the final status message and schedules its cleanup.- Parameters:
msg- the message to show
getDebugCounts
public int[] getDebugCounts()Debug overview counts as {installed, downloaded, available}, where available counts items with an update available from any source, including the internal placeholder.- Returns:
- the counts, never null
renderStatusHTML
Render update manager status HTML for the debug page as one table with two sections - update items, then registered checkers, updaters and post-processors - sharing a column grid so the content aligns. Name, type and method lead, then role, and status is a colored dot with the state as a tooltip.- Specified by:
renderStatusHTMLin interfaceUpdateManager- Parameters:
out- writer to output to- Throws:
IOException- if writing fails
buildUpdateTable
Build the two-section table from the rows of buildItemRows {status, type, name, installed, available, methods} and buildWorkerRows {active, role, class, type, method, version}. Item-only and worker-only columns carry an em-dash in the other section. Package-visible for testing.- Parameters:
items- one row per update itemworkers- one row per registered worker- Returns:
- the table html, never null
buildItemRows
static List<String[]> buildItemRows(Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.Version> installed, Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.Version> downloaded, Map<ConsoleUpdateManager.UpdateItem, ConsoleUpdateManager.VersionAvailable> available, Map<UpdateType, Set<UpdateMethod>> checkMethods) Merge the installed, downloaded and available maps into one row set of {status, type, name, installed, available, methods}, sorted by name. Methods lists the update methods registered as checkers for the item's type. An item present in more than one map yields a single row; the status reflects the most advanced stage: Downloaded, then Available, then Installed. Items with no id (non-plugin updates) get a display name derived from their type. Null maps are treated as empty. Pure, for unit tests.- Parameters:
installed- downloaded and installed versions by itemdownloaded- downloaded but not installed versions by itemavailable- versions reported by checkers by itemcheckMethods- update methods registered as checkers, by type- Returns:
- one row per item, never null
itemDisplayName
Display name for an update item. Plugin items are named by their plugin id; blocklist items combine their id with the type ("Sybil Blocklist"); geoip ids are already readable; the remaining unnamed per-type items get a readable name from their type instead of a dash. Package-visible for testing.- Parameters:
type- the update typeid- the item id, empty for non-plugin items- Returns:
- a display name, never null
versionFor
The installed version string registered for a worker's type, or a dash when that type has no installed version.- Parameters:
typeVersions- installed version strings by type, may be nulltype- the worker's update type- Returns:
- the version or an em-dash
capitalize
buildWorkerRows
static List<String[]> buildWorkerRows(Collection<ConsoleUpdateManager.RegisteredChecker> checkers, Collection<ConsoleUpdateManager.RegisteredUpdater> updaters, Map<Integer, UpdatePostProcessor> postProcessors, Collection<UpdateTask> activeCheckers, Map<UpdateTask, List<ConsoleUpdateManager.RegisteredUpdater>> downloaders, Map<UpdateType, String> typeVersions) Merge the registered checkers, updaters and post-processors into one row set of {active, role, class, type, method, version}, sorted by role then class. A checker is active when a running task matches its type and method; an updater when it is in a running task's remaining list; post-processors have no running state. Null collections are treated as empty. Pure, for unit tests.- Parameters:
checkers- the registered checkers, null treated as emptyupdaters- the registered updaters, null treated as emptypostProcessors- registered post-processors by type idactiveCheckers- currently running check tasksdownloaders- currently running update tasks to their remaining updaterstypeVersions- installed version strings by type, for the worker's Installed/Version cell- Returns:
- one row per registration, never null
fmtVersion
dotClass
Map an item or worker status to its status dot colour: green for installed or active, yellow for an available update, blue for a downloaded update awaiting install, grey otherwise.- Parameters:
status- the row status- Returns:
- a shared.css .appdot colour class, never null