diff --git a/src/FilterLists.Services/Snapshot/Snapshot.cs b/src/FilterLists.Services/Snapshot/Snapshot.cs index 0a6823afb..6a1bb0608 100644 --- a/src/FilterLists.Services/Snapshot/Snapshot.cs +++ b/src/FilterLists.Services/Snapshot/Snapshot.cs @@ -25,6 +25,7 @@ public class Snapshot private readonly string uaString; private HashSet lines; protected string ListUrl; + private bool wasWebException; public Snapshot() { @@ -43,7 +44,7 @@ public Snapshot(BatchSizeService batchSizeService, FilterListsDbContext dbContex telemetryClient = new TelemetryClient(); } - public bool WasSuccessful => SnapEntity.WasSuccessful; + public bool RetryMirror => !SnapEntity.WasSuccessful && wasWebException; public virtual async Task TrySaveAsync() => await TrySaveAsyncBase(); @@ -86,11 +87,13 @@ private async Task TryGetLines() } catch (HttpRequestException hre) { + wasWebException = true; await dbContext.SaveChangesAsync(); TrackException(hre); } catch (WebException we) { + wasWebException = true; SnapEntity.HttpStatusCode = (int)((HttpWebResponse)we.Response).StatusCode; await dbContext.SaveChangesAsync(); TrackException(we); diff --git a/src/FilterLists.Services/Snapshot/SnapshotService.cs b/src/FilterLists.Services/Snapshot/SnapshotService.cs index 7dae4d93b..502543674 100644 --- a/src/FilterLists.Services/Snapshot/SnapshotService.cs +++ b/src/FilterLists.Services/Snapshot/SnapshotService.cs @@ -26,7 +26,7 @@ public async Task CaptureAsync(int batchSize) uaString = await UserAgentService.GetMostPopularString(); var lists = await GetListsToCapture(batchSize); var snaps = await CreateAndSaveSnaps(lists); - var listsToRetry = snaps.Where(s => !s.WasSuccessful).Select(s => s.List); + var listsToRetry = snaps.Where(s => s.RetryMirror).Select(s => s.List); await CreateAndSaveSnaps(listsToRetry); }