Provide a platform override option during web based import (#94)

This commit is contained in:
Michael Green
2023-09-10 11:36:31 +10:00
committed by GitHub
parent d67c17528a
commit 73bcfe2458
3 changed files with 82 additions and 10 deletions

View File

@@ -23,7 +23,7 @@ namespace gaseous_server.Classes
// import files first
foreach (string importContent in importContents_Files) {
ImportGame.ImportGameFile(importContent);
ImportGame.ImportGameFile(importContent, null, false);
}
}
else
@@ -38,7 +38,7 @@ namespace gaseous_server.Classes
public class ImportGame
{
public static void ImportGameFile(string GameFileImportPath, bool IsDirectory = false, bool ForceImport = false)
public static void ImportGameFile(string GameFileImportPath, IGDB.Models.Platform? OverridePlatform, bool IsDirectory = false)
{
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "";
@@ -50,7 +50,6 @@ namespace gaseous_server.Classes
}
else
{
//Logging.Log(Logging.LogType.Information, "Import Game", "Processing item " + GameFileImportPath);
if (IsDirectory == false)
{
FileInfo fi = new FileInfo(GameFileImportPath);
@@ -80,10 +79,20 @@ namespace gaseous_server.Classes
Models.Signatures_Games discoveredSignature = GetFileSignature(hash, fi, GameFileImportPath);
// get discovered platform
IGDB.Models.Platform determinedPlatform = Metadata.Platforms.GetPlatform(discoveredSignature.Flags.IGDBPlatformId);
if (determinedPlatform == null)
IGDB.Models.Platform? determinedPlatform = null;
if (OverridePlatform == null)
{
determinedPlatform = new IGDB.Models.Platform();
determinedPlatform = Metadata.Platforms.GetPlatform(discoveredSignature.Flags.IGDBPlatformId);
if (determinedPlatform == null)
{
determinedPlatform = new IGDB.Models.Platform();
}
}
else
{
determinedPlatform = OverridePlatform;
discoveredSignature.Flags.IGDBPlatformId = (long)determinedPlatform.Id;
discoveredSignature.Flags.IGDBPlatformName = determinedPlatform.Name;
}
IGDB.Models.Game determinedGame = SearchForGame(discoveredSignature.Game.Name, discoveredSignature.Flags.IGDBPlatformId);