Increase and stagger free space probes

This commit is contained in:
DaCoolX
2023-01-09 11:29:40 +01:00
parent a423ba43ba
commit fb110a14bd

View File

@@ -209,12 +209,15 @@ public class Utils {
public static boolean noFreeSpaceOnDisk(String destination_, Log log) { public static boolean noFreeSpaceOnDisk(String destination_, Log log) {
try { try {
File file = new File(destination_); File file = new File(destination_);
for (int i = 0; i < 3; i++) { //We poll repeatedly because getUsableSpace() might just return 0 on busy disk IO for (int i = 0; i < 5; i++) { //We poll repeatedly because getUsableSpace() might just return 0 on busy disk IO
long space = file.getUsableSpace(); long space = file.getUsableSpace();
if (space > 512 * 1024) { // at least the same amount as Server.HTTPGetFile if (space > 512 * 1024) { // at least the same amount as Server.HTTPGetFile
return false; // If we are not "full", we are done, no need for additional polling return false; // If we are not "full", we are done, no need for additional polling
} else if (i < 2) { } else if (i < 4) {
long time = (long) (Math.random() * (100 - 40 + 1) + 40); //Wait between 40 and 100 milliseconds long time = (long) (
Math.random() * (100 - 50 + 1) + 50 + //Wait between 50 and 100 milliseconds,
(i * 500) //add 500 ms on each failed poll
);
log.debug("Utils::Not enough free disk space(" + space + ") encountered on try " + i + ", waiting " + time + "ms"); log.debug("Utils::Not enough free disk space(" + space + ") encountered on try " + i + ", waiting " + time + "ms");
Thread.sleep(time); Thread.sleep(time);
} }