mirror of
https://github.com/SabreTools/SabreTools.RedumpLib.git
synced 2026-02-04 05:36:11 +00:00
Return empty list for no ID matches (#14)
* Return empty list for no ID matches * fix * Deal with null
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user