diff --git a/gaseous-server/Classes/Auth/Classes/UserTable.cs b/gaseous-server/Classes/Auth/Classes/UserTable.cs index 07b3b0d..02c887e 100644 --- a/gaseous-server/Classes/Auth/Classes/UserTable.cs +++ b/gaseous-server/Classes/Auth/Classes/UserTable.cs @@ -400,35 +400,42 @@ namespace Authentication public int SetPreferences(TUser user, List model) { - List userPreferences = GetPreferences(user); - - Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); - - foreach (UserPreferenceViewModel modelItem in model) + if (model != null) { - bool prefItemFound = false; - foreach (UserPreferenceViewModel existing in userPreferences) + List userPreferences = GetPreferences(user); + + Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); + + foreach (UserPreferenceViewModel modelItem in model) { - if (existing.Setting.ToLower() == modelItem.Setting.ToLower()) + bool prefItemFound = false; + foreach (UserPreferenceViewModel existing in userPreferences) { - prefItemFound = true; - break; + if (existing.Setting.ToLower() == modelItem.Setting.ToLower()) + { + prefItemFound = true; + break; + } } + + string sql = "INSERT INTO User_Settings (`Id`, `Setting`, `Value`) VALUES (@id, @setting, @value);"; + if (prefItemFound == true) + { + sql = "UPDATE User_Settings SET `Value`=@value WHERE `Id`=@id AND `Setting`=@setting"; + } + Dictionary dbDict = new Dictionary(); + dbDict.Add("id", user.Id); + dbDict.Add("setting", modelItem.Setting); + dbDict.Add("value", modelItem.Value); + db.ExecuteNonQuery(sql, dbDict); } - string sql = "INSERT INTO User_Settings (`Id`, `Setting`, `Value`) VALUES (@id, @setting, @value);"; - if (prefItemFound == true) - { - sql = "UPDATE User_Settings SET `Value`=@value WHERE `Id`=@id AND `Setting`=@setting"; - } - Dictionary dbDict = new Dictionary(); - dbDict.Add("id", user.Id); - dbDict.Add("setting", modelItem.Setting); - dbDict.Add("value", modelItem.Value); - db.ExecuteNonQuery(sql, dbDict); + return model.Count; + } + else + { + return 0; } - - return model.Count; } } } diff --git a/gaseous-server/Classes/GameLibrary.cs b/gaseous-server/Classes/GameLibrary.cs index 4626aff..7bfd7f6 100644 --- a/gaseous-server/Classes/GameLibrary.cs +++ b/gaseous-server/Classes/GameLibrary.cs @@ -45,6 +45,11 @@ namespace gaseous_server DataRow row = data.Rows[0]; LibraryItem library = new LibraryItem((int)row["Id"], (string)row["Name"], (string)row["Path"], (long)row["DefaultPlatform"], Convert.ToBoolean((int)row["DefaultLibrary"])); + if (!Directory.Exists(library.Path)) + { + Directory.CreateDirectory(library.Path); + } + return library; } } @@ -61,6 +66,15 @@ namespace gaseous_server { LibraryItem library = new LibraryItem((int)row["Id"], (string)row["Name"], (string)row["Path"], (long)row["DefaultPlatform"], Convert.ToBoolean((int)row["DefaultLibrary"])); libraryItems.Add(library); + + if (library.IsDefaultLibrary == true) + { + // check directory exists + if (!Directory.Exists(library.Path)) + { + Directory.CreateDirectory(library.Path); + } + } } return libraryItems; @@ -143,6 +157,11 @@ namespace gaseous_server _Path = Path; _DefaultPlatformId = DefaultPlatformId; _IsDefaultLibrary = IsDefaultLibrary; + + if (!Directory.Exists(Path)) + { + Directory.CreateDirectory(Path); + } } int _Id = 0; diff --git a/gaseous-server/Program.cs b/gaseous-server/Program.cs index 5a99dc6..ad6a1be 100644 --- a/gaseous-server/Program.cs +++ b/gaseous-server/Program.cs @@ -402,6 +402,9 @@ gaseous_server.Classes.Metadata.Platforms.GetPlatform(0); // extract platform map if not present PlatformMapping.ExtractPlatformMap(); +// force load platform map into cache +var platformMap = PlatformMapping.PlatformMap; + // add background tasks ProcessQueue.QueueItems.Add(new ProcessQueue.QueueItem( ProcessQueue.QueueItemType.SignatureIngestor, diff --git a/gaseous-server/Support/Database/MySQL/gaseous-1007.sql b/gaseous-server/Support/Database/MySQL/gaseous-1007.sql index 5c4fb42..19d9572 100644 --- a/gaseous-server/Support/Database/MySQL/gaseous-1007.sql +++ b/gaseous-server/Support/Database/MySQL/gaseous-1007.sql @@ -66,4 +66,11 @@ CREATE TABLE `User_Settings` ( PRIMARY KEY (`Id`, `Setting`)); ALTER TABLE `ServerLogs` -ADD FULLTEXT INDEX `ft_message` USING BTREE (`Message`) VISIBLE; +ADD FULLTEXT INDEX `ft_message` (`Message`) VISIBLE; + +CREATE TABLE `Relation_Game_Platforms` ( + `GameId` BIGINT NOT NULL, + `PlatformsId` BIGINT NOT NULL, + PRIMARY KEY (`GameId`, `PlatformsId`), + INDEX `idx_PrimaryColumn` (`GameId` ASC) VISIBLE +); \ No newline at end of file