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

@@ -80,10 +80,10 @@ public class Utils {
fos.close();
}
catch (IOException e) {
File f = new File(jiniHomeParentDirName_);
if (f.getUsableSpace() == 0) {
if (noFreeSpaceOnDisk(jiniHomeParentDirName_)) {
throw new FermeExceptionNoSpaceLeftOnDevice();
}
Log logger = Log.getInstance(null); // might not print the log since the config is null
logger.error("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + jiniHomeParentDirName_ + ") exception " + e);
return -3;
@@ -239,4 +239,15 @@ public class Utils {
}
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;
}
}