This commit is contained in:
Michael Green
2025-01-09 01:54:24 +11:00
parent f8b9ca3b66
commit 9e93ed1041
2 changed files with 29 additions and 10 deletions

View File

@@ -138,27 +138,43 @@ namespace gaseous_server.Classes.Metadata
break;
case Storage.CacheStatus.Expired:
if (idType == IdType.Long)
try
{
metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result;
if (idType == IdType.Long)
{
metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result;
}
else
{
metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result;
}
Storage.NewCacheValue<T>(SourceType, metadata, true);
}
else
catch (Exception e)
{
metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result;
Logging.Log(Logging.LogType.Warning, "Fetch Metadata", "Failed to fetch metadata from source: " + SourceType + " for id: " + Id + " of type: " + type + ". Error: " + e.Message);
metadata = null;
}
Storage.NewCacheValue<T>(SourceType, metadata, true);
break;
case Storage.CacheStatus.NotPresent:
if (idType == IdType.Long)
try
{
metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result;
if (idType == IdType.Long)
{
metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result;
}
else
{
metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result;
}
Storage.NewCacheValue<T>(SourceType, metadata, false);
}
else
catch (Exception e)
{
metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result;
Logging.Log(Logging.LogType.Warning, "Fetch Metadata", "Failed to fetch metadata from source: " + SourceType + " for id: " + Id + " of type: " + type + ". Error: " + e.Message);
metadata = null;
}
Storage.NewCacheValue<T>(SourceType, metadata, false);
break;
}

View File

@@ -808,6 +808,9 @@ namespace gaseous_server.Controllers
MetadataMap filteredMetadataMap = new MetadataMap();
filteredMetadataMap.MetadataMapItems = metadataMap.MetadataMapItems.Where(x => x.SourceType != HasheousClient.Models.MetadataSources.TheGamesDb).ToList();
// further filter out metadataMapItems where sourceId = 0
filteredMetadataMap.MetadataMapItems = filteredMetadataMap.MetadataMapItems.Where(x => x.SourceId != 0).ToList();
metadataMap.MetadataMapItems = filteredMetadataMap.MetadataMapItems;
return Ok(metadataMap);