Bugfix: wrong next request time detection

This commit is contained in:
Laurent Clouet
2019-03-06 21:12:08 +01:00
parent 388ec6fee5
commit f68be624db

View File

@@ -162,8 +162,13 @@ public class Client {
// wait
Date now = new Date();
this.gui.status(String.format("Waiting until %tR before requesting job", next_request));
long wait = next_request.getTimeInMillis() - now.getTime();
if (wait < 0) {
// it means the client has to wait until the next day
wait += 24*3600*1000;
}
try {
Thread.sleep(next_request.getTimeInMillis() - now.getTime());
Thread.sleep(wait);
}
catch (InterruptedException e3) {
@@ -551,16 +556,9 @@ public class Client {
if (start.before(now) && now.before(end)) {
return null;
}
if (start.after(now)) {
if (next == null) {
if (next == null || (start.before(next) && start.after(now))) {
next = start;
}
else {
if (start.before(next)) {
next = start;
}
}
}
}
return next;