Ignore bad json files when loading repos

This commit is contained in:
Timothy Baldridge 2022-09-18 21:15:39 -06:00
parent 85fa3d2c99
commit 9ee8bd8cd9

View File

@ -7,6 +7,7 @@ using System.Net.Http;
using System.Net.Http.Json;
using System.Reactive.Subjects;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
@ -198,14 +199,25 @@ public class Client
var featured = await LoadFeaturedLists();
return await (await repos).PMapAll(async url =>
(await _client.GetFromJsonAsync<ModlistMetadata[]>(_limiter,
{
try
{
return (await _client.GetFromJsonAsync<ModlistMetadata[]>(_limiter,
new HttpRequestMessage(HttpMethod.Get, url.Value),
_dtos.Options))!.Select(meta =>
{
meta.RepositoryName = url.Key;
meta.Official = (meta.RepositoryName == "wj-featured" || featured.Contains(meta.NamespacedName));
meta.Official = (meta.RepositoryName == "wj-featured" ||
featured.Contains(meta.NamespacedName));
return meta;
}))
});
}
catch (JsonException ex)
{
_logger.LogError(ex, "While loading {List} from {Url}", url.Key, url.Value);
return Enumerable.Empty<ModlistMetadata>();
}
})
.SelectMany(x => x)
.ToArray();
}