Skip to content

Commit

Permalink
optimize check conditions and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Mar 27, 2024
1 parent 0c38173 commit 2fb638d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ public WorldStats() {
}

private void refresh() {
if (scan_result.get() != null && (System.currentTimeMillis() <= scan_result.get().expiration_time_millis || scanning)) {
if (scanning) {
return;
}

scanning = true;
if (scan_result.get() != null && scan_result.get().expiration_time_millis > System.currentTimeMillis()) {
return;
}

scanning = true; // Mark as scanning to avoid scheduling another check while there is already one running

CompletableFuture.supplyAsync(() -> new FileScanResult(config.paths_to_scan, config.filesize_update_period_millis)).thenAccept(result -> {
scan_result.set(result);
Expand Down

0 comments on commit 2fb638d

Please # to comment.