Skip to content

Commit

Permalink
Always fetch when stale content is not allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Westberg committed Oct 12, 2020
1 parent 52f6c1c commit 99b05e7
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,19 @@ private void refreshSeed(boolean allowStale) throws IOException {
}

var seedRepo = Repository.get(seed).orElseThrow(() -> new IOException("Existing seed is corrupt?"));
try {
var lastFetch = Files.getLastModifiedTime(seed.resolve("FETCH_HEAD"));
if (lastFetch.toInstant().isAfter(Instant.now().minus(Duration.ofMinutes(1)))) {
log.info("Seed should be up to date, skipping fetch");
return;
if (allowStale) {
try {
var lastFetch = Files.getLastModifiedTime(seed.resolve("FETCH_HEAD"));
if (lastFetch.toInstant().isAfter(Instant.now().minus(Duration.ofMinutes(1)))) {
log.info("Seed should be up to date, skipping fetch");
return;
}
} catch (IOException ignored) {
}
} catch (IOException ignored) {
log.info("Seed is potentially stale, time to fetch the latest upstream changes");
} else {
log.info("Fetching latest upstream changes into the seed");
}
log.info("Seed is potentially stale, time to refresh it");
try {
seedRepo.fetchAll();
} catch (IOException e) {
Expand Down

0 comments on commit 99b05e7

Please sign in to comment.