fix NRE when OrderedItems is null (and log it, I'm curious) (#38)

This commit is contained in:
Gervasio Marchand 2023-02-09 09:26:25 -03:00 committed by GitHub
parent 91ac0e2385
commit 6fd7804d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,13 +121,19 @@ await Parallel.ForEachAsync(sitesTags, new ParallelOptions{MaxDegreeOfParallelis
return;
}
int count = 0;
foreach (var statusLink in data.OrderedItems.Where(i=>!imported.Contains(i)))
if (data.OrderedItems == null)
{
Console.WriteLine($"Got null on OrderedItems when pulling #{tag} posts from {site}");
return;
}
var count = 0;
foreach (var statusLink in data.OrderedItems.Where(i => !imported.Contains(i)))
{
statusesToLoadBag.Add(statusLink);
count++;
}
Console.WriteLine($"Retrieved {count} new statuses from {site} with hashtag #{tag}");
});
@ -164,7 +170,7 @@ File.WriteAllLines(importedPath, importedList);
public class TagResponse
{
public string[] OrderedItems { get; }
public string[]? OrderedItems { get; }
public TagResponse(string[] orderedItems)
{