Skip to content

Commit

Permalink
Handle failure to retrieve status when testing advisory cache age (#4337
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sigurdm authored Aug 15, 2024
1 parent 8ab5be0 commit 9de221d
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 @@ -783,10 +783,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 9de221d

Please sign in to comment.