diff --git a/gaseous-server/Classes/ImportGames.cs b/gaseous-server/Classes/ImportGames.cs index 108951d..6379011 100644 --- a/gaseous-server/Classes/ImportGames.cs +++ b/gaseous-server/Classes/ImportGames.cs @@ -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); diff --git a/gaseous-server/Controllers/RomsController.cs b/gaseous-server/Controllers/RomsController.cs index 7a4ad6b..32b0668 100644 --- a/gaseous-server/Controllers/RomsController.cs +++ b/gaseous-server/Controllers/RomsController.cs @@ -25,7 +25,7 @@ namespace gaseous_server.Controllers [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] [RequestSizeLimit(long.MaxValue)] [DisableRequestSizeLimit, RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue, ValueLengthLimit = int.MaxValue)] - public async Task UploadRom(List files) + public async Task UploadRom(List files, long? OverridePlatformId = null) { Guid sessionid = Guid.NewGuid(); @@ -61,12 +61,17 @@ namespace gaseous_server.Controllers } } - // Process uploaded files - // Don't rely on or trust the FileName property without validation. + // get override platform if specified + IGDB.Models.Platform? OverridePlatform = null; + if (OverridePlatformId != null) + { + OverridePlatform = Platforms.GetPlatform((long)OverridePlatformId); + } + // Process uploaded files foreach (Dictionary UploadedFile in UploadedFiles) { - Classes.ImportGame.ImportGameFile((string)UploadedFile["fullpath"]); + Classes.ImportGame.ImportGameFile((string)UploadedFile["fullpath"], OverridePlatform, false); } if (Directory.Exists(workPath)) diff --git a/gaseous-server/wwwroot/pages/dialogs/upload.html b/gaseous-server/wwwroot/pages/dialogs/upload.html index a913b59..7d71bb3 100644 --- a/gaseous-server/wwwroot/pages/dialogs/upload.html +++ b/gaseous-server/wwwroot/pages/dialogs/upload.html @@ -12,9 +12,20 @@
+ + + + + +
+ Override automatic platform detection: + + +
\ No newline at end of file