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,6 +138,8 @@ namespace gaseous_server.Classes.Metadata
break; break;
case Storage.CacheStatus.Expired: case Storage.CacheStatus.Expired:
try
{
if (idType == IdType.Long) if (idType == IdType.Long)
{ {
metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result; metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result;
@@ -147,9 +149,17 @@ namespace gaseous_server.Classes.Metadata
metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result; metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result;
} }
Storage.NewCacheValue<T>(SourceType, metadata, true); Storage.NewCacheValue<T>(SourceType, metadata, true);
}
catch (Exception e)
{
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;
}
break; break;
case Storage.CacheStatus.NotPresent: case Storage.CacheStatus.NotPresent:
try
{
if (idType == IdType.Long) if (idType == IdType.Long)
{ {
metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result; metadata = GetMetadataFromServer<T>(SourceType, (long)Id).Result;
@@ -159,6 +169,12 @@ namespace gaseous_server.Classes.Metadata
metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result; metadata = GetMetadataFromServer<T>(SourceType, (string)Id).Result;
} }
Storage.NewCacheValue<T>(SourceType, metadata, false); Storage.NewCacheValue<T>(SourceType, metadata, false);
}
catch (Exception e)
{
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;
}
break; break;
} }

View File

@@ -808,6 +808,9 @@ namespace gaseous_server.Controllers
MetadataMap filteredMetadataMap = new MetadataMap(); MetadataMap filteredMetadataMap = new MetadataMap();
filteredMetadataMap.MetadataMapItems = metadataMap.MetadataMapItems.Where(x => x.SourceType != HasheousClient.Models.MetadataSources.TheGamesDb).ToList(); 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; metadataMap.MetadataMapItems = filteredMetadataMap.MetadataMapItems;
return Ok(metadataMap); return Ok(metadataMap);