Skip to content

Commit

Permalink
Handle failure to retrieve status when testing advisory cache age
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm committed Aug 1, 2024
1 parent 1957001 commit 9a03800
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/src/source/hosted.dart
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,14 @@ class HostedSource extends CachedSource {
}
final parsedCacheAdvisoriesUpdated =
DateTime.parse(cachedAdvisoriesUpdated);
if ((await status(id.toRef(), id.version, cache))
.advisoriesUpdated!
.isAfter(parsedCacheAdvisoriesUpdated)) {
// too old
final advisoriesUpdated =
(await status(id.toRef(), id.version, cache)).advisoriesUpdated;

if (
// We could not obtain the timestamp of latest advisory update.
advisoriesUpdated == null ||
// The cached entry is too old.
advisoriesUpdated.isAfter(parsedCacheAdvisoriesUpdated)) {
tryDeleteEntry(advisoriesCachePath);
} else {
return _extractAdvisoryDetailsForPackage(doc, id.toRef().name);
Expand Down

0 comments on commit 9a03800

Please sign in to comment.