Skip to content

Commit

Permalink
[JENKINS-32886] Pick up missing downloads on restart (#2345)
Browse files Browse the repository at this point in the history
* [JENKINS-32886] Pick up missing downloads

* [JENKINS-32886] Improve error handling.
  • Loading branch information
andresrc authored and oleg-nenashev committed May 15, 2016
1 parent b651234 commit 5762eb9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/main/java/jenkins/model/DownloadSettings.java
Expand Up @@ -29,10 +29,13 @@
import hudson.model.AdministrativeMonitor;
import hudson.model.AsyncPeriodicWork;
import hudson.model.DownloadService;
import hudson.model.DownloadService.Downloadable;
import hudson.model.TaskListener;
import hudson.model.UpdateSite;
import hudson.util.FormValidation;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.json.JSONObject;
import org.acegisecurity.AccessDeniedException;
import org.jenkinsci.Symbol;
Expand Down Expand Up @@ -91,6 +94,7 @@ public static void checkPostBackAccess() throws AccessDeniedException {

@Extension @Symbol("updateCenterCheck")
public static final class DailyCheck extends AsyncPeriodicWork {
private static final Logger LOGGER = Logger.getLogger(DailyCheck.class.getName());

public DailyCheck() {
super("Download metadata");
Expand All @@ -116,8 +120,21 @@ public DailyCheck() {
}
}
if (!due) {
// JENKINS-32886: downloadables like the tool installer data may have never been tried if the plugin
// was installed "after a restart", so let's give them a try here.
final long now = System.currentTimeMillis();
for (Downloadable d : Downloadable.all()) {
if (d.getDue() <= now) {
try {
d.updateNow();
} catch(Exception e) {
LOGGER.log(Level.WARNING, String.format("Unable to update downloadable [%s]", d.getId()), e);
}
}
}
return;
}
// This checks updates of the update sites and downloadables.
HttpResponse rsp = Jenkins.getInstance().getPluginManager().doCheckUpdatesServer();
if (rsp instanceof FormValidation) {
listener.error(((FormValidation) rsp).renderHtml());
Expand Down

0 comments on commit 5762eb9

Please sign in to comment.