Do not report download for cached resources

Moves the UI update code into downloadFile(), after the check to see if
the file is already cached, to avoid reporting that the client is
downloading files when it isn't.
This commit is contained in:
AGSPhoenix
2016-01-13 09:47:41 +01:00
committed by Laurent Clouet
parent 79bfdd71ac
commit d1a03fa4a8

View File

@@ -533,22 +533,24 @@ public class Client {
} }
protected int downloadSceneFile(Job ajob_) { protected int downloadSceneFile(Job ajob_) {
this.gui.status("Downloading project"); return this.downloadFile(ajob_, ajob_.getSceneArchivePath(), ajob_.getSceneMD5(), String.format("%s?type=job&job=%s&revision=%s", this.server.getPage("download-archive"), ajob_.getId(), ajob_.getRevision()), "project");
return this.downloadFile(ajob_, ajob_.getSceneArchivePath(), ajob_.getSceneMD5(), String.format("%s?type=job&job=%s&revision=%s", this.server.getPage("download-archive"), ajob_.getId(), ajob_.getRevision()), "Downloading project %s %%");
} }
protected int downloadExecutable(Job ajob) { protected int downloadExecutable(Job ajob) {
this.gui.status("Downloading renderer"); return this.downloadFile(ajob, ajob.getRendererArchivePath(), ajob.getRenderMd5(), String.format("%s?type=binary&job=%s", this.server.getPage("download-archive"), ajob.getId()), "renderer");
return this.downloadFile(ajob, ajob.getRendererArchivePath(), ajob.getRenderMd5(), String.format("%s?type=binary&job=%s", this.server.getPage("download-archive"), ajob.getId()), "Downloading renderer %s %%");
} }
private int downloadFile(Job ajob, String local_path, String md5_server, String url, String update_ui) { private int downloadFile(Job ajob, String local_path, String md5_server, String url, String download_type) {
File local_path_file = new File(local_path); File local_path_file = new File(local_path);
String update_ui = "Downloading " + download_type + " %s %%";
if (local_path_file.exists() == true) { if (local_path_file.exists() == true) {
this.gui.status("Reusing cached " + download_type);
return 0; return 0;
} }
this.gui.status("Downloading " + download_type);
// must download the archive // must download the archive
int ret = this.server.HTTPGetFile(url, local_path, this.gui, update_ui); int ret = this.server.HTTPGetFile(url, local_path, this.gui, update_ui);
boolean md5_check = this.checkFile(ajob, local_path, md5_server); boolean md5_check = this.checkFile(ajob, local_path, md5_server);