Skip to content

Commit

Permalink
Fixed async cache race condition
Browse files Browse the repository at this point in the history
Remove tag before starting to prevent multiple runs
  • Loading branch information
cjmalloy committed Aug 9, 2024
1 parent c9f72e3 commit 2ee3577
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/jasper/component/delta/AsyncCacheScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jasper.component.ConfigCache;
import jasper.component.FileCache;
import jasper.component.Tagger;
import jasper.domain.Ref;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -25,6 +26,9 @@ public class AsyncCacheScraper implements Async.AsyncRunner {
@Autowired
ConfigCache configs;

@Autowired
Tagger tagger;

@PostConstruct
void init() {
async.addAsyncTag("_plugin/delta/cache", this);
Expand All @@ -33,6 +37,7 @@ void init() {
@Override
public void run(Ref ref) throws Exception {
logger.info("{} Caching {}", ref.getOrigin(), ref.getUrl());
tagger.tag(ref.getUrl(), ref.getOrigin(), "-_plugin/delta/cache", "_plugin/cache");
fileCache.refresh(ref.getUrl(), ref.getOrigin());
}
}

0 comments on commit 2ee3577

Please sign in to comment.