This commit is contained in:
Michael Green
2025-01-10 17:35:29 +11:00
parent a0a8495597
commit 86c207e389
7 changed files with 48 additions and 16 deletions

View File

@@ -246,6 +246,19 @@ namespace gaseous_server.Classes
} }
} }
// get all tables that have the prefix "Relation_" and drop them
sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = @dbname AND table_name LIKE 'Relation_%';";
dbDict = new Dictionary<string, object>
{
{ "dbname", Config.DatabaseConfiguration.DatabaseName }
};
data = db.ExecuteCMD(sql, dbDict);
foreach (DataRow row in data.Rows)
{
sql = "DROP TABLE " + (string)row["table_name"] + ";";
db.ExecuteNonQuery(sql);
}
// migrating metadata is a safe background task // migrating metadata is a safe background task
BackgroundUpgradeTargetSchemaVersions.Add(1024); BackgroundUpgradeTargetSchemaVersions.Add(1024);
break; break;

View File

@@ -163,12 +163,14 @@ namespace gaseous_server.Classes
Platform? determinedPlatform = Metadata.Platforms.GetPlatform((long)discoveredSignature.Flags.PlatformId); Platform? determinedPlatform = Metadata.Platforms.GetPlatform((long)discoveredSignature.Flags.PlatformId);
Models.Game? determinedGame = Metadata.Games.GetGame(discoveredSignature.Flags.GameMetadataSource, discoveredSignature.Flags.GameId); Models.Game? determinedGame = Metadata.Games.GetGame(discoveredSignature.Flags.GameMetadataSource, discoveredSignature.Flags.GameId);
long RomId = StoreGame(GameLibrary.GetDefaultLibrary, Hash, discoveredSignature, determinedPlatform, FilePath, 0, true); long RomId = StoreGame(GameLibrary.GetDefaultLibrary, Hash, discoveredSignature, determinedPlatform, FilePath, 0, true);
Roms.GameRomItem romItem = Roms.GetRom(RomId);
// build return value // build return value
GameFileInfo.Add("romid", RomId); GameFileInfo.Add("romid", RomId);
GameFileInfo.Add("platform", determinedPlatform); GameFileInfo.Add("platform", determinedPlatform);
GameFileInfo.Add("game", determinedGame); GameFileInfo.Add("game", determinedGame);
GameFileInfo.Add("signature", discoveredSignature); GameFileInfo.Add("signature", discoveredSignature);
GameFileInfo.Add("rom", romItem);
GameFileInfo.Add("status", "imported"); GameFileInfo.Add("status", "imported");
} }
} }
@@ -479,8 +481,9 @@ namespace gaseous_server.Classes
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId); Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
// get metadata // get metadata
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(rom.MetadataMapId).PreferredMetadataMapItem;
Platform? platform = gaseous_server.Classes.Metadata.Platforms.GetPlatform(rom.PlatformId); Platform? platform = gaseous_server.Classes.Metadata.Platforms.GetPlatform(rom.PlatformId);
gaseous_server.Models.Game? game = gaseous_server.Classes.Metadata.Games.GetGame(Config.MetadataConfiguration.DefaultMetadataSource, rom.GameId); gaseous_server.Models.Game? game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
// build path // build path
string platformSlug = "Unknown Platform"; string platformSlug = "Unknown Platform";

View File

@@ -27,7 +27,7 @@ namespace gaseous_server.Classes.Metadata
{ {
Id = 0, Id = 0,
Name = "Unknown Platform", Name = "Unknown Platform",
Slug = "Unknown" Slug = "unknown"
}; };
Storage.NewCacheValue(Source, returnValue); Storage.NewCacheValue(Source, returnValue);

View File

@@ -107,7 +107,10 @@ namespace gaseous_server.Models
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.None, platform); Storage.NewCacheValue(HasheousClient.Models.MetadataSources.None, platform);
} }
if (Config.MetadataConfiguration.SignatureSource == HasheousClient.Models.MetadataModel.SignatureSources.Hasheous)
{
Communications.PopulateHasheousPlatformData(mapItem.IGDBId); Communications.PopulateHasheousPlatformData(mapItem.IGDBId);
}
if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "Platform", mapItem.IGDBId) == Storage.CacheStatus.NotPresent) if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "Platform", mapItem.IGDBId) == Storage.CacheStatus.NotPresent)
{ {
@@ -318,15 +321,15 @@ namespace gaseous_server.Models
// get platform data // get platform data
Platform? platform = null; Platform? platform = null;
// if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.None, "Platform", IGDBId) == Storage.CacheStatus.NotPresent) if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.None, "Platform", IGDBId) == Storage.CacheStatus.NotPresent)
// { {
// //platform = Platforms.GetPlatform(IGDBId, false); //platform = Platforms.GetPlatform(IGDBId, false);
// } }
// else else
// { {
// platform = (Platform)Storage.GetCacheValue<Platform>(HasheousClient.Models.MetadataSources.None, new Platform(), "id", IGDBId); // platform = (Platform)Storage.GetCacheValue<Platform>(HasheousClient.Models.MetadataSources.None, new Platform(), "id", IGDBId);
// }
platform = Platforms.GetPlatform(IGDBId, HasheousClient.Models.MetadataSources.None); platform = Platforms.GetPlatform(IGDBId, HasheousClient.Models.MetadataSources.None);
}
if (platform != null) if (platform != null)
{ {

View File

@@ -11,6 +11,7 @@ using Authentication;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using gaseous_server.Classes.Metadata; using gaseous_server.Classes.Metadata;
using Asp.Versioning; using Asp.Versioning;
using HasheousClient.Models.Metadata.IGDB;
Logging.WriteToDiskOnly = true; Logging.WriteToDiskOnly = true;
Logging.Log(Logging.LogType.Information, "Startup", "Starting Gaseous Server " + Assembly.GetExecutingAssembly().GetName().Version); Logging.Log(Logging.LogType.Information, "Startup", "Starting Gaseous Server " + Assembly.GetExecutingAssembly().GetName().Version);
@@ -329,6 +330,11 @@ app.Use(async (context, next) =>
// setup library directories // setup library directories
Config.LibraryConfiguration.InitLibrary(); Config.LibraryConfiguration.InitLibrary();
// create unknown platform
Platforms.GetPlatform(0, HasheousClient.Models.MetadataSources.None);
Platforms.GetPlatform(0, HasheousClient.Models.MetadataSources.IGDB);
Platforms.GetPlatform(0, HasheousClient.Models.MetadataSources.TheGamesDb);
// extract platform map if not present // extract platform map if not present
PlatformMapping.ExtractPlatformMap(); PlatformMapping.ExtractPlatformMap();

View File

@@ -109,6 +109,7 @@ class UploadRom {
if (xhr.status === 200) { if (xhr.status === 200) {
// process the results // process the results
let response = JSON.parse(xhr.responseText); let response = JSON.parse(xhr.responseText);
console.log(response);
switch (response.type) { switch (response.type) {
case 'rom': case 'rom':
switch (response.status) { switch (response.status) {
@@ -121,16 +122,21 @@ class UploadRom {
uploadedItem.platformName = 'Unknown Platform'; uploadedItem.platformName = 'Unknown Platform';
uploadedItem.gameId = 0; uploadedItem.gameId = 0;
uploadedItem.gameName = 'Unknown Game'; uploadedItem.gameName = 'Unknown Game';
uploadedItem.gameData = response.game;
uploadedItem.romId = response.romid; uploadedItem.romId = response.romid;
if (response.game) { if (response.game) {
uploadedItem.gameId = response.game.metadataMapId; // game data was returned
uploadedItem.gameId = response.rom.metadataMapId;
uploadedItem.gameName = response.game.name; uploadedItem.gameName = response.game.name;
if (response.game.cover != null) { if (response.game.cover != null) {
if (response.game.cover != null) { if (response.game.cover != null) {
uploadedItem.coverId = response.game.cover; uploadedItem.coverId = response.game.cover;
} }
} }
} else {
// game has been deemed to be unknown
uploadedItem.gameId = response.rom.metadataMapId;
} }
if (response.platform) { if (response.platform) {
@@ -273,6 +279,7 @@ class UploadItem {
platformName = null; platformName = null;
gameId = null; gameId = null;
gameName = null; gameName = null;
gameData = null;
coverId = null; coverId = null;
romId = null; romId = null;
@@ -319,7 +326,7 @@ class UploadItem {
case 'rom': case 'rom':
this.infoButton.style.display = 'block'; this.infoButton.style.display = 'block';
if (this.gameId === null || this.gameId === 0) { if (this.gameId === null || this.gameId === 0 || this.gameData === null) {
this.coverArt.src = '/images/unknowngame.png'; this.coverArt.src = '/images/unknowngame.png';
} else { } else {
this.coverArt.src = '/api/v1.1/Games/' + this.gameId + '/cover/' + this.coverId + '/image/cover_big/cover.jpg'; this.coverArt.src = '/api/v1.1/Games/' + this.gameId + '/cover/' + this.coverId + '/image/cover_big/cover.jpg';