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 // wait
Date now = new Date(); Date now = new Date();
this.gui.status(String.format("Waiting until %tR before requesting job", next_request)); 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 { try {
Thread.sleep(next_request.getTimeInMillis() - now.getTime()); Thread.sleep(wait);
} }
catch (InterruptedException e3) { catch (InterruptedException e3) {
@@ -551,15 +556,8 @@ public class Client {
if (start.before(now) && now.before(end)) { if (start.before(now) && now.before(end)) {
return null; return null;
} }
if (start.after(now)) { if (next == null || (start.before(next) && start.after(now))) {
if (next == null) { next = start;
next = start;
}
else {
if (start.before(next)) {
next = start;
}
}
} }
} }