Skip to content

Commit

Permalink
Miscellaneous bug fixes (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-j-green authored Dec 9, 2023
1 parent 8401763 commit 7b241ee
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
51 changes: 29 additions & 22 deletions gaseous-server/Classes/Auth/Classes/UserTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,35 +400,42 @@ public List<UserPreferenceViewModel> GetPreferences(TUser user)

public int SetPreferences(TUser user, List<UserPreferenceViewModel> model)
{
List<UserPreferenceViewModel> 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<UserPreferenceViewModel> 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";
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<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", user.Id);
dbDict.Add("setting", modelItem.Setting);
dbDict.Add("value", modelItem.Value);
db.ExecuteNonQuery(sql, dbDict);
}
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", user.Id);
dbDict.Add("setting", modelItem.Setting);
dbDict.Add("value", modelItem.Value);
db.ExecuteNonQuery(sql, dbDict);
}

return model.Count;
return model.Count;
}
else
{
return 0;
}
}
}
}
19 changes: 19 additions & 0 deletions gaseous-server/Classes/GameLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static LibraryItem GetDefaultLibrary
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;
}
}
Expand All @@ -61,6 +66,15 @@ public static List<LibraryItem> GetLibraries
{
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;
Expand Down Expand Up @@ -143,6 +157,11 @@ public LibraryItem(int Id, string Name, string Path, long DefaultPlatformId, boo
_Path = Path;
_DefaultPlatformId = DefaultPlatformId;
_IsDefaultLibrary = IsDefaultLibrary;

if (!Directory.Exists(Path))
{
Directory.CreateDirectory(Path);
}
}

int _Id = 0;
Expand Down
3 changes: 3 additions & 0 deletions gaseous-server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@
// 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,
Expand Down
9 changes: 8 additions & 1 deletion gaseous-server/Support/Database/MySQL/gaseous-1007.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

0 comments on commit 7b241ee

Please sign in to comment.