Return empty list for no ID matches (#14)

* Return empty list for no ID matches

* fix

* Deal with null
This commit is contained in:
Deterous
2026-02-02 23:02:39 +09:00
committed by GitHub
parent e832723b40
commit 0b309e1cb8
4 changed files with 18 additions and 8 deletions

View File

@@ -110,7 +110,9 @@ namespace SabreTools.RedumpLib
int pageNumber = 1;
while (true)
{
List<int> pageIds = await rc.CheckSingleSitePage(string.Format(Constants.QuickSearchUrl, query, pageNumber++));
List<int>? pageIds = await rc.CheckSingleSitePage(string.Format(Constants.QuickSearchUrl, query, pageNumber++));
if (pageIds is null)
return null;
ids.AddRange(pageIds);
if (pageIds.Count <= 1)
break;
@@ -141,9 +143,9 @@ namespace SabreTools.RedumpLib
if (newIds is null)
return null;
// If no IDs match, just return
// If no IDs match, return an empty list
if (newIds.Count == 0)
return null;
return [];
// Join the list of found IDs to the existing list, if possible
if (info.PartiallyMatchedIDs is not null && info.PartiallyMatchedIDs.Count > 0)
@@ -185,9 +187,9 @@ namespace SabreTools.RedumpLib
if (newIds is null)
return null;
// If no IDs match, just return
// If no IDs match, just an empty list
if (newIds.Count == 0)
return null;
return [];
// Join the list of found IDs to the existing list, if possible
if (info.PartiallyMatchedIDs is not null && info.PartiallyMatchedIDs.Count > 0)

View File

@@ -299,15 +299,19 @@ namespace SabreTools.RedumpLib.Web
/// </summary>
/// <param name="url">Base URL to download using</param>
/// <returns>List of IDs from the page, empty on error</returns>
public async Task<List<int>> CheckSingleSitePage(string url)
public async Task<List<int>?> CheckSingleSitePage(string url)
{
List<int> ids = [];
// Try to retrieve the data
string? dumpsPage = await DownloadString(url);
// If the web client failed, return null
if (dumpsPage is null)
return null;
// If we have no dumps left
if (dumpsPage is null || dumpsPage.Contains("No discs found."))
if (dumpsPage.Contains("No discs found."))
return ids;
// If we have a single disc page already

View File

@@ -43,7 +43,9 @@ namespace SabreTools.RedumpLib.Web
int pageNumber = 1;
while (true)
{
List<int> pageIds = await rc.CheckSingleSitePage(string.Format(Constants.QuickSearchUrl, query, pageNumber++));
var pageIds = await rc.CheckSingleSitePage(string.Format(Constants.QuickSearchUrl, query, pageNumber++));
if (pageIds is null)
return [];
ids.AddRange(pageIds);
if (pageIds.Count <= 1)
break;

View File

@@ -93,6 +93,8 @@ namespace SabreTools.RedumpLib.Web
while (true)
{
var pageIds = await rc.CheckSingleSitePage(string.Format(Constants.UserDumpsUrl, username, pageNumber++));
if (pageIds is null)
return [];
ids.AddRange(pageIds);
if (pageIds.Count <= 1)
break;