add ability to disable updates completely, intended for 3rd party packaging

This commit is contained in:
Zlatin Balevsky
2020-09-26 17:53:29 +01:00
parent 3387d22a6c
commit 72985bacb6
5 changed files with 21 additions and 8 deletions

View File

@ -329,13 +329,13 @@ public class Core {
log.info("initializing cache client")
cacheClient = new CacheClient(eventBus,hostCache, connectionManager, i2pSession, props, 10000)
if (!props.plugin) {
if (!(props.plugin || props.disableUpdates)) {
log.info("initializing update client")
updateClient = new UpdateClient(eventBus, i2pSession, myVersion, props, fileManager, me, spk)
eventBus.register(FileDownloadedEvent.class, updateClient)
eventBus.register(UIResultBatchEvent.class, updateClient)
} else
log.info("running as plugin, not initializing update client")
log.info("running as plugin or updates disabled, not initializing update client")
log.info("initializing connector")
I2PConnector i2pConnector = new I2PConnector(i2pSocketManager)

View File

@ -57,6 +57,7 @@ class MuWireSettings {
int speedSmoothSeconds
boolean embeddedRouter
boolean plugin
boolean disableUpdates
int inBw, outBw
Set<String> watchedKeywords
Set<String> watchedRegexes
@ -95,6 +96,7 @@ class MuWireSettings {
meshExpiration = Integer.valueOf(props.getProperty("meshExpiration","60"))
embeddedRouter = Boolean.valueOf(props.getProperty("embeddedRouter","false"))
plugin = Boolean.valueOf(props.getProperty("plugin","false"))
disableUpdates = Boolean.valueOf(props.getProperty("disableUpdates","false"))
inBw = Integer.valueOf(props.getProperty("inBw","256"))
outBw = Integer.valueOf(props.getProperty("outBw","128"))
searchComments = Boolean.valueOf(props.getProperty("searchComments","true"))
@ -170,6 +172,7 @@ class MuWireSettings {
props.setProperty("meshExpiration", String.valueOf(meshExpiration))
props.setProperty("embeddedRouter", String.valueOf(embeddedRouter))
props.setProperty("plugin", String.valueOf(plugin))
props.setProperty("disableUpdates", String.valueOf(disableUpdates))
props.setProperty("inBw", String.valueOf(inBw))
props.setProperty("outBw", String.valueOf(outBw))
props.setProperty("searchComments", String.valueOf(searchComments))

View File

@ -50,6 +50,9 @@ class Ready extends AbstractLifecycleHandler {
props = new MuWireSettings(props)
if (props.incompleteLocation == null)
props.incompleteLocation = new File(home, "incompletes")
if (System.getProperties().containsKey("disableUpdates"))
props.disableUpdates = Boolean.valueOf(System.getProperty("disableUpdates"))
} else {
log.info("creating new properties")
props = new MuWireSettings()
@ -88,6 +91,7 @@ class Ready extends AbstractLifecycleHandler {
props.embeddedRouter = embeddedRouterAvailable
props.updateType = System.getProperty("updateType","jar")
props.disableUpdates = Boolean.parseBoolean(System.getProperty("disableUpdates", "false"))
propsFile.withPrintWriter("UTF-8", {

View File

@ -75,6 +75,8 @@ class OptionsModel {
@Observable boolean advertiseChat
@Observable int maxChatLines
@Observable String chatWelcomeFile
boolean disableUpdates
void mvcGroupInit(Map<String, String> args) {
MuWireSettings settings = application.context.get("muwire-settings")
@ -139,5 +141,7 @@ class OptionsModel {
advertiseChat = settings.advertiseChat
maxChatLines = uiSettings.maxChatLines
chatWelcomeFile = settings.chatWelcomeFile?.getAbsolutePath()
disableUpdates = settings.disableUpdates
}
}

View File

@ -158,16 +158,18 @@ class OptionsView {
shareHiddenCheckbox = checkBox(selected : bind {model.shareHiddenFiles}, constraints : gbc(gridx :1, gridy:1, weightx : 0))
}
panel (border : titledBorder(title : "Update Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP,
if (!model.disableUpdates) {
panel (border : titledBorder(title : "Update Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP,
constraints : gbc(gridx : 0, gridy : 4, fill : GridBagConstraints.HORIZONTAL))) {
gridBagLayout()
label(text : "Check for updates every (hours)", constraints : gbc(gridx : 0, gridy: 0, anchor : GridBagConstraints.LINE_START, weightx : 100))
updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 0, weightx: 0))
gridBagLayout()
label(text : "Check for updates every (hours)", constraints : gbc(gridx : 0, gridy: 0, anchor : GridBagConstraints.LINE_START, weightx : 100))
updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 0, weightx: 0))
label(text : "Download updates automatically", constraints: gbc(gridx :0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx: 100))
autoDownloadUpdateCheckbox = checkBox(selected : bind {model.autoDownloadUpdate},
label(text : "Download updates automatically", constraints: gbc(gridx :0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx: 100))
autoDownloadUpdateCheckbox = checkBox(selected : bind {model.autoDownloadUpdate},
constraints : gbc(gridx:1, gridy : 1, anchor : GridBagConstraints.LINE_END))
}
}
}
i = builder.panel {