Detect full hard drive on file download

This commit is contained in:
Laurent Clouet
2016-06-25 13:45:09 +02:00
parent dc63b9791b
commit f04b84468d
3 changed files with 22 additions and 6 deletions

View File

@@ -77,6 +77,7 @@ import com.sheepit.client.Error.ServerCode;
import com.sheepit.client.exception.FermeException;
import com.sheepit.client.exception.FermeExceptionNoRightToRender;
import com.sheepit.client.exception.FermeExceptionNoSession;
import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice;
import com.sheepit.client.exception.FermeExceptionServerInMaintenance;
import com.sheepit.client.exception.FermeExceptionServerOverloaded;
import com.sheepit.client.exception.FermeExceptionSessionDisabled;
@@ -536,7 +537,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
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
try {
HttpURLConnection httpCon = this.HTTPRequest(url_);
@@ -570,6 +571,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
return 0;
}
catch (Exception e) {
if (Utils.noFreeSpaceOnDisk(destination_)) {
throw new FermeExceptionNoSpaceLeftOnDevice();
}
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
this.log.error("Server::HTTPGetFile exception " + e + " stacktrace " + sw.toString());