Detect full hard drive on file download
This commit is contained in:
@@ -577,15 +577,15 @@ public class Client {
|
|||||||
return Error.Type.OK;
|
return Error.Type.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int downloadSceneFile(Job ajob_) {
|
protected int downloadSceneFile(Job ajob_) throws FermeExceptionNoSpaceLeftOnDevice {
|
||||||
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()), "project");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int downloadExecutable(Job ajob) {
|
protected int downloadExecutable(Job ajob) throws FermeExceptionNoSpaceLeftOnDevice {
|
||||||
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()), "renderer");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int downloadFile(Job ajob, String local_path, String md5_server, String url, String download_type) {
|
private int downloadFile(Job ajob, String local_path, String md5_server, String url, String download_type) throws FermeExceptionNoSpaceLeftOnDevice {
|
||||||
File local_path_file = new File(local_path);
|
File local_path_file = new File(local_path);
|
||||||
String update_ui = "Downloading " + download_type + " %s %%";
|
String update_ui = "Downloading " + download_type + " %s %%";
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ import com.sheepit.client.Error.ServerCode;
|
|||||||
import com.sheepit.client.exception.FermeException;
|
import com.sheepit.client.exception.FermeException;
|
||||||
import com.sheepit.client.exception.FermeExceptionNoRightToRender;
|
import com.sheepit.client.exception.FermeExceptionNoRightToRender;
|
||||||
import com.sheepit.client.exception.FermeExceptionNoSession;
|
import com.sheepit.client.exception.FermeExceptionNoSession;
|
||||||
|
import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice;
|
||||||
import com.sheepit.client.exception.FermeExceptionServerInMaintenance;
|
import com.sheepit.client.exception.FermeExceptionServerInMaintenance;
|
||||||
import com.sheepit.client.exception.FermeExceptionServerOverloaded;
|
import com.sheepit.client.exception.FermeExceptionServerOverloaded;
|
||||||
import com.sheepit.client.exception.FermeExceptionSessionDisabled;
|
import com.sheepit.client.exception.FermeExceptionSessionDisabled;
|
||||||
@@ -536,7 +537,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int HTTPGetFile(String url_, String destination_, Gui gui_, String status_) {
|
public int HTTPGetFile(String url_, String destination_, Gui gui_, String status_) throws FermeExceptionNoSpaceLeftOnDevice {
|
||||||
// the destination_ parent directory must exist
|
// the destination_ parent directory must exist
|
||||||
try {
|
try {
|
||||||
HttpURLConnection httpCon = this.HTTPRequest(url_);
|
HttpURLConnection httpCon = this.HTTPRequest(url_);
|
||||||
@@ -570,6 +571,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
if (Utils.noFreeSpaceOnDisk(destination_)) {
|
||||||
|
throw new FermeExceptionNoSpaceLeftOnDevice();
|
||||||
|
}
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
e.printStackTrace(new PrintWriter(sw));
|
||||||
this.log.error("Server::HTTPGetFile exception " + e + " stacktrace " + sw.toString());
|
this.log.error("Server::HTTPGetFile exception " + e + " stacktrace " + sw.toString());
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ public class Utils {
|
|||||||
fos.close();
|
fos.close();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
File f = new File(jiniHomeParentDirName_);
|
if (noFreeSpaceOnDisk(jiniHomeParentDirName_)) {
|
||||||
if (f.getUsableSpace() == 0) {
|
|
||||||
throw new FermeExceptionNoSpaceLeftOnDevice();
|
throw new FermeExceptionNoSpaceLeftOnDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log logger = Log.getInstance(null); // might not print the log since the config is null
|
Log logger = Log.getInstance(null); // might not print the log since the config is null
|
||||||
logger.error("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + jiniHomeParentDirName_ + ") exception " + e);
|
logger.error("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + jiniHomeParentDirName_ + ") exception " + e);
|
||||||
return -3;
|
return -3;
|
||||||
@@ -239,4 +239,15 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean noFreeSpaceOnDisk(String destination_) {
|
||||||
|
try {
|
||||||
|
File file = new File(destination_);
|
||||||
|
return (file.getUsableSpace() < 512 * 1024); // at least the same amount as Server.HTTPGetFile
|
||||||
|
}
|
||||||
|
catch (SecurityException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user