mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
make sure we don't refresh a feed twice in a row
This commit is contained in:
@@ -119,14 +119,24 @@ public class FeedRefreshEngine implements Managed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshImmediately(Feed feed) {
|
public void refreshImmediately(Feed feed) {
|
||||||
|
// remove the feed from the queue if it was already queued to avoid refreshing it twice
|
||||||
|
queue.removeIf(f -> f.getId().equals(feed.getId()));
|
||||||
queue.addFirst(feed);
|
queue.addFirst(feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refillQueueAsync() {
|
private void refillQueueAsync() {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
if (queue.isEmpty()) {
|
if (!queue.isEmpty()) {
|
||||||
refill.mark();
|
return;
|
||||||
queue.addAll(getNextUpdatableFeeds(getBatchSize()));
|
}
|
||||||
|
|
||||||
|
refill.mark();
|
||||||
|
|
||||||
|
for (Feed feed : getNextUpdatableFeeds(getBatchSize())) {
|
||||||
|
// add the feed only if it was not already queued
|
||||||
|
if (queue.stream().noneMatch(f -> f.getId().equals(feed.getId()))) {
|
||||||
|
queue.addLast(feed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, refillExecutor).whenComplete((data, ex) -> {
|
}, refillExecutor).whenComplete((data, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user