Commit ddc648c6 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Thread runs only when enabled and also when module is started.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4201 b35dd754-fafc-0310-a699-88a17e54d16e
parent c53d65a3
...@@ -102,29 +102,22 @@ public class UpdateManager extends BasicModule { ...@@ -102,29 +102,22 @@ public class UpdateManager extends BasicModule {
Thread.sleep(15000); Thread.sleep(15000);
// Load last saved information (if any) // Load last saved information (if any)
loadSavedInfo(); loadSavedInfo();
while (true) { while (isServiceEnabled()) {
// Check if the service is enabled waitForNextChecking();
// Check if the service is still enabled
if (isServiceEnabled()) { if (isServiceEnabled()) {
waitForNextChecking(); try {
// Check if the service is still enabled // Check for server updates
if (isServiceEnabled()) { checkForServerUpdate(true);
try { // Refresh list of available plugins and check for plugin updates
// Check for server updates checkForPluginsUpdates(true);
checkForServerUpdate(true); // Keep track of the last time we checked for updates
// Refresh list of available plugins and check for plugin updates JiveGlobals.setProperty("update.lastCheck",
checkForPluginsUpdates(true); String.valueOf(System.currentTimeMillis()));
// Keep track of the last time we checked for updates }
JiveGlobals.setProperty("update.lastCheck", catch (Exception e) {
String.valueOf(System.currentTimeMillis())); Log.error("Error checking for updates", e);
}
catch (Exception e) {
Log.error("Error checking for updates", e);
}
} }
}
else {
// Service is not enabled so sleep for 5 minutes
Thread.sleep(300000);
} }
} }
} }
...@@ -306,6 +299,9 @@ public class UpdateManager extends BasicModule { ...@@ -306,6 +299,9 @@ public class UpdateManager extends BasicModule {
*/ */
public void setServiceEnabled(boolean enabled) { public void setServiceEnabled(boolean enabled) {
JiveGlobals.setProperty("update.service-enabled", enabled ? "true" : "false"); JiveGlobals.setProperty("update.service-enabled", enabled ? "true" : "false");
if (enabled && thread == null) {
startService();
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment