From d1a03fa4a8c3fa304ab6bd32d9d10b0d52eab67f Mon Sep 17 00:00:00 2001 From: AGSPhoenix Date: Wed, 13 Jan 2016 09:47:41 +0100 Subject: [PATCH] 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. --- src/com/sheepit/client/Client.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 155eeb7..c6e8954 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -533,22 +533,24 @@ public class Client { } 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()), "Downloading project %s %%"); + 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"); } 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()), "Downloading renderer %s %%"); + return this.downloadFile(ajob, ajob.getRendererArchivePath(), ajob.getRenderMd5(), String.format("%s?type=binary&job=%s", this.server.getPage("download-archive"), ajob.getId()), "renderer"); } - 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); + String update_ui = "Downloading " + download_type + " %s %%"; if (local_path_file.exists() == true) { + this.gui.status("Reusing cached " + download_type); return 0; } + this.gui.status("Downloading " + download_type); + // must download the archive int ret = this.server.HTTPGetFile(url, local_path, this.gui, update_ui); boolean md5_check = this.checkFile(ajob, local_path, md5_server);