only try Wayback on web exceptions

ref #325
This commit is contained in:
Collin M. Barrett 2018-08-25 07:55:28 -05:00
parent c6c41bf671
commit aebc3f336c
2 changed files with 5 additions and 2 deletions

View file

@ -25,6 +25,7 @@ public class Snapshot
private readonly string uaString;
private HashSet<string> 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);

View file

@ -26,7 +26,7 @@ public async Task CaptureAsync(int batchSize)
uaString = await UserAgentService.GetMostPopularString();
var lists = await GetListsToCapture(batchSize);
var snaps = await CreateAndSaveSnaps<Snapshot>(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<SnapshotWayback>(listsToRetry);
}