Compare commits
6 Commits
branch-v1.
...
branch-v1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e4cffb6fb4 | ||
![]() |
0e125d42ec | ||
![]() |
6d110731c4 | ||
![]() |
de628e6766 | ||
![]() |
308338580d | ||
![]() |
49784dc325 |
@@ -1,176 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Data;
|
|
||||||
using gaseous_server.Classes.Metadata;
|
|
||||||
using gaseous_tools;
|
|
||||||
using IGDB.Models;
|
|
||||||
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow;
|
|
||||||
|
|
||||||
namespace gaseous_server
|
|
||||||
{
|
|
||||||
public static class GameLibrary
|
|
||||||
{
|
|
||||||
// exceptions
|
|
||||||
public class PathExists : Exception
|
|
||||||
{
|
|
||||||
public PathExists(string path) : base("The library path " + path + " already exists.")
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PathNotFound : Exception
|
|
||||||
{
|
|
||||||
public PathNotFound(string path) : base("The path " + path + " does not exist.")
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LibraryNotFound : Exception
|
|
||||||
{
|
|
||||||
public LibraryNotFound(int LibraryId) : base("Library id " + LibraryId + " does not exist.")
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CannotDeleteDefaultLibrary : Exception
|
|
||||||
{
|
|
||||||
public CannotDeleteDefaultLibrary() : base("Unable to delete the default library.")
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// code
|
|
||||||
public static LibraryItem GetDefaultLibrary
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
string sql = "SELECT * FROM GameLibraries WHERE DefaultLibrary=1 LIMIT 1";
|
|
||||||
DataTable data = db.ExecuteCMD(sql);
|
|
||||||
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"]));
|
|
||||||
|
|
||||||
return library;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<LibraryItem> GetLibraries
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
List<LibraryItem> libraryItems = new List<LibraryItem>();
|
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
string sql = "SELECT * FROM GameLibraries";
|
|
||||||
DataTable data = db.ExecuteCMD(sql);
|
|
||||||
foreach (DataRow row in data.Rows)
|
|
||||||
{
|
|
||||||
LibraryItem library = new LibraryItem((int)row["Id"], (string)row["Name"], (string)row["Path"], (long)row["DefaultPlatform"], Convert.ToBoolean((int)row["DefaultLibrary"]));
|
|
||||||
libraryItems.Add(library);
|
|
||||||
}
|
|
||||||
|
|
||||||
return libraryItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LibraryItem AddLibrary(string Name, string Path, long DefaultPlatformId)
|
|
||||||
{
|
|
||||||
string PathName = Common.NormalizePath(Path);
|
|
||||||
|
|
||||||
// check path isn't already in place
|
|
||||||
foreach (LibraryItem item in GetLibraries)
|
|
||||||
{
|
|
||||||
if (Common.NormalizePath(PathName) == Common.NormalizePath(item.Path))
|
|
||||||
{
|
|
||||||
// already existing path!
|
|
||||||
throw new PathExists(PathName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!System.IO.Path.Exists(PathName))
|
|
||||||
{
|
|
||||||
throw new PathNotFound(PathName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
string sql = "INSERT INTO GameLibraries (Name, Path, DefaultPlatform, DefaultLibrary) VALUES (@name, @path, @defaultplatform, 0); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
|
||||||
dbDict.Add("name", Name);
|
|
||||||
dbDict.Add("path", PathName);
|
|
||||||
dbDict.Add("defaultplatform", DefaultPlatformId);
|
|
||||||
DataTable data = db.ExecuteCMD(sql, dbDict);
|
|
||||||
|
|
||||||
int newLibraryId = (int)(long)data.Rows[0][0];
|
|
||||||
|
|
||||||
return GetLibrary(newLibraryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DeleteLibrary(int LibraryId)
|
|
||||||
{
|
|
||||||
if (GetLibrary(LibraryId).IsDefaultLibrary == false)
|
|
||||||
{
|
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
string sql = "DELETE FROM Games_Roms WHERE LibraryId=@id; DELETE FROM GameLibraries WHERE Id=@id;";
|
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
|
||||||
dbDict.Add("id", LibraryId);
|
|
||||||
db.ExecuteCMD(sql, dbDict);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new CannotDeleteDefaultLibrary();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LibraryItem GetLibrary(int LibraryId)
|
|
||||||
{
|
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
string sql = "SELECT * FROM GameLibraries WHERE Id=@id";
|
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
|
||||||
dbDict.Add("id", LibraryId);
|
|
||||||
DataTable data = db.ExecuteCMD(sql, dbDict);
|
|
||||||
if (data.Rows.Count > 0)
|
|
||||||
{
|
|
||||||
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"]));
|
|
||||||
return library;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new LibraryNotFound(LibraryId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LibraryItem
|
|
||||||
{
|
|
||||||
public LibraryItem(int Id, string Name, string Path, long DefaultPlatformId, bool IsDefaultLibrary)
|
|
||||||
{
|
|
||||||
_Id = Id;
|
|
||||||
_Name = Name;
|
|
||||||
_Path = Path;
|
|
||||||
_DefaultPlatformId = DefaultPlatformId;
|
|
||||||
_IsDefaultLibrary = IsDefaultLibrary;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _Id = 0;
|
|
||||||
string _Name = "";
|
|
||||||
string _Path = "";
|
|
||||||
long _DefaultPlatformId = 0;
|
|
||||||
bool _IsDefaultLibrary = false;
|
|
||||||
|
|
||||||
public int Id => _Id;
|
|
||||||
public string Name => _Name;
|
|
||||||
public string Path => _Path;
|
|
||||||
public long DefaultPlatformId => _DefaultPlatformId;
|
|
||||||
public string? DefaultPlatformName
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_DefaultPlatformId != 0)
|
|
||||||
{
|
|
||||||
Platform platform = Platforms.GetPlatform(_DefaultPlatformId);
|
|
||||||
return platform.Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool IsDefaultLibrary => _IsDefaultLibrary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -4,7 +4,6 @@ using System.IO.Compression;
|
|||||||
using System.Security.Policy;
|
using System.Security.Policy;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using gaseous_server.Classes.Metadata;
|
|
||||||
using gaseous_tools;
|
using gaseous_tools;
|
||||||
using IGDB.Models;
|
using IGDB.Models;
|
||||||
using MySqlX.XDevAPI;
|
using MySqlX.XDevAPI;
|
||||||
@@ -99,7 +98,7 @@ namespace gaseous_server.Classes
|
|||||||
IGDB.Models.Game determinedGame = SearchForGame(discoveredSignature.Game.Name, discoveredSignature.Flags.IGDBPlatformId);
|
IGDB.Models.Game determinedGame = SearchForGame(discoveredSignature.Game.Name, discoveredSignature.Flags.IGDBPlatformId);
|
||||||
|
|
||||||
// add to database
|
// add to database
|
||||||
StoreROM(GameLibrary.GetDefaultLibrary, hash, determinedGame, determinedPlatform, discoveredSignature, GameFileImportPath);
|
StoreROM(hash, determinedGame, determinedPlatform, discoveredSignature, GameFileImportPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -392,7 +391,7 @@ namespace gaseous_server.Classes
|
|||||||
return SearchCandidates;
|
return SearchCandidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long StoreROM(GameLibrary.LibraryItem library, Common.hashObject hash, IGDB.Models.Game determinedGame, IGDB.Models.Platform determinedPlatform, Models.Signatures_Games discoveredSignature, string GameFileImportPath, long UpdateId = 0)
|
public static long StoreROM(Common.hashObject hash, IGDB.Models.Game determinedGame, IGDB.Models.Platform determinedPlatform, Models.Signatures_Games discoveredSignature, string GameFileImportPath, long UpdateId = 0)
|
||||||
{
|
{
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
|
||||||
@@ -402,7 +401,7 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
if (UpdateId == 0)
|
if (UpdateId == 0)
|
||||||
{
|
{
|
||||||
sql = "INSERT INTO Games_Roms (PlatformId, GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Attributes, RomType, RomTypeMedia, MediaLabel, Path, MetadataSource, MetadataGameName, MetadataVersion, LibraryId) VALUES (@platformid, @gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @Attributes, @romtype, @romtypemedia, @medialabel, @path, @metadatasource, @metadatagamename, @metadataversion, @libraryid); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
sql = "INSERT INTO Games_Roms (PlatformId, GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Attributes, RomType, RomTypeMedia, MediaLabel, Path, MetadataSource, MetadataGameName, MetadataVersion) VALUES (@platformid, @gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @Attributes, @romtype, @romtypemedia, @medialabel, @path, @metadatasource, @metadatagamename, @metadataversion); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
sql = "UPDATE Games_Roms SET PlatformId=platformid, GameId=@gameid, Name=@name, Size=@size, DevelopmentStatus=@developmentstatus, Attributes=@Attributes, RomType=@romtype, RomTypeMedia=@romtypemedia, MediaLabel=@medialabel, MetadataSource=@metadatasource, MetadataGameName=@metadatagamename, MetadataVersion=@metadataversion WHERE Id=@id;";
|
sql = "UPDATE Games_Roms SET PlatformId=platformid, GameId=@gameid, Name=@name, Size=@size, DevelopmentStatus=@developmentstatus, Attributes=@Attributes, RomType=@romtype, RomTypeMedia=@romtypemedia, MediaLabel=@medialabel, MetadataSource=@metadatasource, MetadataGameName=@metadatagamename, MetadataVersion=@metadataversion WHERE Id=@id;";
|
||||||
@@ -419,7 +418,6 @@ namespace gaseous_server.Classes
|
|||||||
dbDict.Add("metadatasource", discoveredSignature.Rom.SignatureSource);
|
dbDict.Add("metadatasource", discoveredSignature.Rom.SignatureSource);
|
||||||
dbDict.Add("metadatagamename", discoveredSignature.Game.Name);
|
dbDict.Add("metadatagamename", discoveredSignature.Game.Name);
|
||||||
dbDict.Add("metadataversion", 2);
|
dbDict.Add("metadataversion", 2);
|
||||||
dbDict.Add("libraryid", library.Id);
|
|
||||||
|
|
||||||
if (discoveredSignature.Rom.Attributes != null)
|
if (discoveredSignature.Rom.Attributes != null)
|
||||||
{
|
{
|
||||||
@@ -452,10 +450,7 @@ namespace gaseous_server.Classes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move to destination
|
// move to destination
|
||||||
if (library.IsDefaultLibrary == true)
|
|
||||||
{
|
|
||||||
MoveGameFile(romId);
|
MoveGameFile(romId);
|
||||||
}
|
|
||||||
|
|
||||||
return romId;
|
return romId;
|
||||||
}
|
}
|
||||||
@@ -479,7 +474,7 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
gameSlug = game.Slug;
|
gameSlug = game.Slug;
|
||||||
}
|
}
|
||||||
string DestinationPath = Path.Combine(GameLibrary.GetDefaultLibrary.Path, gameSlug, platformSlug);
|
string DestinationPath = Path.Combine(Config.LibraryConfiguration.LibraryDataDirectory, gameSlug, platformSlug);
|
||||||
if (!Directory.Exists(DestinationPath))
|
if (!Directory.Exists(DestinationPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(DestinationPath);
|
Directory.CreateDirectory(DestinationPath);
|
||||||
@@ -537,16 +532,12 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
public static void OrganiseLibrary()
|
public static void OrganiseLibrary()
|
||||||
{
|
{
|
||||||
Logging.Log(Logging.LogType.Information, "Organise Library", "Starting default library organisation");
|
Logging.Log(Logging.LogType.Information, "Organise Library", "Starting library organisation");
|
||||||
|
|
||||||
GameLibrary.LibraryItem library = GameLibrary.GetDefaultLibrary;
|
|
||||||
|
|
||||||
// move rom files to their new location
|
// move rom files to their new location
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
string sql = "SELECT * FROM Games_Roms WHERE LibraryId = @libraryid";
|
string sql = "SELECT * FROM Games_Roms";
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
DataTable romDT = db.ExecuteCMD(sql);
|
||||||
dbDict.Add("libraryid", library.Id);
|
|
||||||
DataTable romDT = db.ExecuteCMD(sql, dbDict);
|
|
||||||
|
|
||||||
if (romDT.Rows.Count > 0)
|
if (romDT.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -559,9 +550,9 @@ namespace gaseous_server.Classes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clean up empty directories
|
// clean up empty directories
|
||||||
DeleteOrphanedDirectories(GameLibrary.GetDefaultLibrary.Path);
|
DeleteOrphanedDirectories(Config.LibraryConfiguration.LibraryDataDirectory);
|
||||||
|
|
||||||
Logging.Log(Logging.LogType.Information, "Organise Library", "Finsihed default library organisation");
|
Logging.Log(Logging.LogType.Information, "Organise Library", "Finsihed library organisation");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeleteOrphanedDirectories(string startLocation)
|
private static void DeleteOrphanedDirectories(string startLocation)
|
||||||
@@ -579,22 +570,16 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
public static void LibraryScan()
|
public static void LibraryScan()
|
||||||
{
|
{
|
||||||
foreach (GameLibrary.LibraryItem library in GameLibrary.GetLibraries)
|
Logging.Log(Logging.LogType.Information, "Library Scan", "Starting library scan");
|
||||||
{
|
|
||||||
Logging.Log(Logging.LogType.Information, "Library Scan", "Starting library scan. Library " + library.Name);
|
|
||||||
|
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
|
||||||
Logging.Log(Logging.LogType.Information, "Library Scan", "Looking for duplicate library files to clean up");
|
Logging.Log(Logging.LogType.Information, "Library Scan", "Looking for duplicate library files to clean up");
|
||||||
string duplicateSql = "DELETE r1 FROM Games_Roms r1 INNER JOIN Games_Roms r2 WHERE r1.Id > r2.Id AND r1.MD5 = r2.MD5 AND r1.LibraryId=@libraryid AND r2.LibraryId=@libraryid;";
|
string duplicateSql = "DELETE r1 FROM Games_Roms r1 INNER JOIN Games_Roms r2 WHERE r1.Id > r2.Id AND r1.MD5 = r2.MD5;";
|
||||||
Dictionary<string, object> dupDict = new Dictionary<string, object>();
|
db.ExecuteCMD(duplicateSql);
|
||||||
dupDict.Add("libraryid", library.Id);
|
|
||||||
db.ExecuteCMD(duplicateSql, dupDict);
|
|
||||||
|
|
||||||
string sql = "SELECT * FROM Games_Roms WHERE LibraryId=@libraryid ORDER BY `name`";
|
string sql = "SELECT * FROM Games_Roms ORDER BY `name`";
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
DataTable dtRoms = db.ExecuteCMD(sql);
|
||||||
dbDict.Add("libraryid", library.Id);
|
|
||||||
DataTable dtRoms = db.ExecuteCMD(sql, dbDict);
|
|
||||||
|
|
||||||
// clean out database entries in the import folder
|
// clean out database entries in the import folder
|
||||||
if (dtRoms.Rows.Count > 0)
|
if (dtRoms.Rows.Count > 0)
|
||||||
@@ -604,24 +589,23 @@ namespace gaseous_server.Classes
|
|||||||
long romId = (long)dtRoms.Rows[i]["Id"];
|
long romId = (long)dtRoms.Rows[i]["Id"];
|
||||||
string romPath = (string)dtRoms.Rows[i]["Path"];
|
string romPath = (string)dtRoms.Rows[i]["Path"];
|
||||||
|
|
||||||
if (!romPath.StartsWith(library.Path))
|
if (!romPath.StartsWith(Config.LibraryConfiguration.LibraryDataDirectory))
|
||||||
{
|
{
|
||||||
Logging.Log(Logging.LogType.Information, "Library Scan", " Deleting database entry for files with incorrect directory " + romPath);
|
Logging.Log(Logging.LogType.Information, "Library Scan", " Deleting database entry for files with incorrect directory " + romPath);
|
||||||
string deleteSql = "DELETE FROM Games_Roms WHERE Id=@id AND LibraryId=@libraryid";
|
string deleteSql = "DELETE FROM Games_Roms WHERE Id=@id";
|
||||||
Dictionary<string, object> deleteDict = new Dictionary<string, object>();
|
Dictionary<string, object> deleteDict = new Dictionary<string, object>();
|
||||||
deleteDict.Add("Id", romId);
|
deleteDict.Add("Id", romId);
|
||||||
deleteDict.Add("libraryid", library.Id);
|
|
||||||
db.ExecuteCMD(deleteSql, deleteDict);
|
db.ExecuteCMD(deleteSql, deleteDict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "SELECT * FROM Games_Roms ORDER BY `name`";
|
sql = "SELECT * FROM Games_Roms ORDER BY `name`";
|
||||||
dtRoms = db.ExecuteCMD(sql, dbDict);
|
dtRoms = db.ExecuteCMD(sql);
|
||||||
|
|
||||||
// search for files in the library that aren't in the database
|
// search for files in the library that aren't in the database
|
||||||
Logging.Log(Logging.LogType.Information, "Library Scan", "Looking for orphaned library files to add");
|
Logging.Log(Logging.LogType.Information, "Library Scan", "Looking for orphaned library files to add");
|
||||||
string[] LibraryFiles = Directory.GetFiles(library.Path, "*.*", SearchOption.AllDirectories);
|
string[] LibraryFiles = Directory.GetFiles(Config.LibraryConfiguration.LibraryDataDirectory, "*.*", SearchOption.AllDirectories);
|
||||||
foreach (string LibraryFile in LibraryFiles)
|
foreach (string LibraryFile in LibraryFiles)
|
||||||
{
|
{
|
||||||
if (!Common.SkippableFiles.Contains<string>(Path.GetFileName(LibraryFile), StringComparer.OrdinalIgnoreCase))
|
if (!Common.SkippableFiles.Contains<string>(Path.GetFileName(LibraryFile), StringComparer.OrdinalIgnoreCase))
|
||||||
@@ -655,33 +639,20 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
// get discovered platform
|
// get discovered platform
|
||||||
IGDB.Models.Platform determinedPlatform = Metadata.Platforms.GetPlatform(sig.Flags.IGDBPlatformId);
|
IGDB.Models.Platform determinedPlatform = Metadata.Platforms.GetPlatform(sig.Flags.IGDBPlatformId);
|
||||||
|
|
||||||
IGDB.Models.Game determinedGame = new Game();
|
|
||||||
if (determinedPlatform == null)
|
if (determinedPlatform == null)
|
||||||
{
|
|
||||||
if (library.DefaultPlatformId == 0)
|
|
||||||
{
|
{
|
||||||
determinedPlatform = new IGDB.Models.Platform();
|
determinedPlatform = new IGDB.Models.Platform();
|
||||||
determinedGame = SearchForGame(sig.Game.Name, sig.Flags.IGDBPlatformId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
determinedPlatform = Platforms.GetPlatform(library.DefaultPlatformId);
|
|
||||||
determinedGame = SearchForGame(sig.Game.Name, library.DefaultPlatformId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
determinedGame = SearchForGame(sig.Game.Name, (long)determinedPlatform.Id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StoreROM(library, hash, determinedGame, determinedPlatform, sig, LibraryFile);
|
IGDB.Models.Game determinedGame = SearchForGame(sig.Game.Name, sig.Flags.IGDBPlatformId);
|
||||||
|
|
||||||
|
StoreROM(hash, determinedGame, determinedPlatform, sig, LibraryFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "SELECT * FROM Games_Roms WHERE LibraryId=@libraryid ORDER BY `name`";
|
sql = "SELECT * FROM Games_Roms ORDER BY `name`";
|
||||||
dtRoms = db.ExecuteCMD(sql, dbDict);
|
dtRoms = db.ExecuteCMD(sql);
|
||||||
|
|
||||||
// check all roms to see if their local file still exists
|
// check all roms to see if their local file still exists
|
||||||
Logging.Log(Logging.LogType.Information, "Library Scan", "Checking library files exist on disk");
|
Logging.Log(Logging.LogType.Information, "Library Scan", "Checking library files exist on disk");
|
||||||
@@ -724,27 +695,23 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
IGDB.Models.Game determinedGame = SearchForGame(sig.Game.Name, sig.Flags.IGDBPlatformId);
|
IGDB.Models.Game determinedGame = SearchForGame(sig.Game.Name, sig.Flags.IGDBPlatformId);
|
||||||
|
|
||||||
StoreROM(library, hash, determinedGame, determinedPlatform, sig, romPath, romId);
|
StoreROM(hash, determinedGame, determinedPlatform, sig, romPath, romId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (library.IsDefaultLibrary == true)
|
|
||||||
{
|
|
||||||
if (romPath != ComputeROMPath(romId))
|
if (romPath != ComputeROMPath(romId))
|
||||||
{
|
{
|
||||||
MoveGameFile(romId);
|
MoveGameFile(romId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// file doesn't exist where it's supposed to be! delete it from the db
|
// file doesn't exist where it's supposed to be! delete it from the db
|
||||||
Logging.Log(Logging.LogType.Warning, "Library Scan", " Deleting orphaned database entry for " + romPath);
|
Logging.Log(Logging.LogType.Warning, "Library Scan", " Deleting orphaned database entry for " + romPath);
|
||||||
|
|
||||||
string deleteSql = "DELETE FROM Games_Roms WHERE Id = @id AND LibraryId = @libraryid";
|
string deleteSql = "DELETE FROM Games_Roms WHERE Id = @id";
|
||||||
Dictionary<string, object> deleteDict = new Dictionary<string, object>();
|
Dictionary<string, object> deleteDict = new Dictionary<string, object>();
|
||||||
deleteDict.Add("id", romId);
|
deleteDict.Add("id", romId);
|
||||||
deleteDict.Add("libraryid", library.Id);
|
|
||||||
db.ExecuteCMD(deleteSql, deleteDict);
|
db.ExecuteCMD(deleteSql, deleteDict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -753,6 +720,5 @@ namespace gaseous_server.Classes
|
|||||||
Logging.Log(Logging.LogType.Information, "Library Scan", "Library scan completed");
|
Logging.Log(Logging.LogType.Information, "Library Scan", "Library scan completed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@ using System.Reflection;
|
|||||||
using gaseous_tools;
|
using gaseous_tools;
|
||||||
using IGDB;
|
using IGDB;
|
||||||
using IGDB.Models;
|
using IGDB.Models;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
|
||||||
namespace gaseous_server.Classes.Metadata
|
namespace gaseous_server.Classes.Metadata
|
||||||
{
|
{
|
||||||
@@ -16,15 +17,33 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
Expired
|
Expired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Dictionary<string, MemoryCacheObject> ObjectCache = new Dictionary<string, MemoryCacheObject>();
|
||||||
|
|
||||||
public static CacheStatus GetCacheStatus(string Endpoint, string Slug)
|
public static CacheStatus GetCacheStatus(string Endpoint, string Slug)
|
||||||
|
{
|
||||||
|
CacheClean();
|
||||||
|
if (ObjectCache.ContainsKey(Endpoint + Slug))
|
||||||
|
{
|
||||||
|
return CacheStatus.Current;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return _GetCacheStatus(Endpoint, "slug", Slug);
|
return _GetCacheStatus(Endpoint, "slug", Slug);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static CacheStatus GetCacheStatus(string Endpoint, long Id)
|
public static CacheStatus GetCacheStatus(string Endpoint, long Id)
|
||||||
{
|
{
|
||||||
|
CacheClean();
|
||||||
|
if (ObjectCache.ContainsKey(Endpoint + Id))
|
||||||
|
{
|
||||||
|
return CacheStatus.Current;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return _GetCacheStatus(Endpoint, "id", Id);
|
return _GetCacheStatus(Endpoint, "id", Id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static CacheStatus GetCacheStatus(DataRow Row)
|
public static CacheStatus GetCacheStatus(DataRow Row)
|
||||||
{
|
{
|
||||||
@@ -164,6 +183,21 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
string Endpoint = EndpointType.GetType().Name;
|
string Endpoint = EndpointType.GetType().Name;
|
||||||
|
|
||||||
|
if (ObjectCache.ContainsKey(Endpoint + SearchValue))
|
||||||
|
{
|
||||||
|
MemoryCacheObject cacheObject = ObjectCache[Endpoint + SearchValue];
|
||||||
|
if (cacheObject.ExpiryTime < DateTime.UtcNow)
|
||||||
|
{
|
||||||
|
// object has expired, remove it
|
||||||
|
ObjectCache.Remove(Endpoint + SearchValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// object is valid, return it
|
||||||
|
return (T)cacheObject.Object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
|
||||||
string sql = "SELECT * FROM " + Endpoint + " WHERE " + SearchField + " = @" + SearchField;
|
string sql = "SELECT * FROM " + Endpoint + " WHERE " + SearchField + " = @" + SearchField;
|
||||||
@@ -181,7 +215,11 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
DataRow dataRow = dt.Rows[0];
|
DataRow dataRow = dt.Rows[0];
|
||||||
return BuildCacheObject<T>(EndpointType, dataRow);
|
object returnObject = BuildCacheObject<T>(EndpointType, dataRow);
|
||||||
|
ObjectCache.Add(Endpoint + SearchValue, new MemoryCacheObject{
|
||||||
|
Object = returnObject
|
||||||
|
});
|
||||||
|
return (T)returnObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,6 +418,35 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
|
|
||||||
return EndpointType;
|
return EndpointType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CacheClean()
|
||||||
|
{
|
||||||
|
if (ObjectCache == null)
|
||||||
|
{
|
||||||
|
ObjectCache = new Dictionary<string, MemoryCacheObject>();
|
||||||
|
}
|
||||||
|
Dictionary<string, MemoryCacheObject> workCache = ObjectCache;
|
||||||
|
foreach (KeyValuePair<string, MemoryCacheObject> objectCache in workCache)
|
||||||
|
{
|
||||||
|
if (objectCache.Value.ExpiryTime < DateTime.UtcNow)
|
||||||
|
{
|
||||||
|
ObjectCache.Remove(objectCache.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MemoryCacheObject
|
||||||
|
{
|
||||||
|
public object Object { get; set; }
|
||||||
|
public DateTime CreationTime { get; } = DateTime.UtcNow;
|
||||||
|
public DateTime ExpiryTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return CreationTime.AddMinutes(60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,8 +81,6 @@ namespace gaseous_server.Classes
|
|||||||
public static void DeleteRom(long RomId)
|
public static void DeleteRom(long RomId)
|
||||||
{
|
{
|
||||||
GameRomItem rom = GetRom(RomId);
|
GameRomItem rom = GetRom(RomId);
|
||||||
if (rom.Library.IsDefaultLibrary == true)
|
|
||||||
{
|
|
||||||
if (File.Exists(rom.Path))
|
if (File.Exists(rom.Path))
|
||||||
{
|
{
|
||||||
File.Delete(rom.Path);
|
File.Delete(rom.Path);
|
||||||
@@ -94,7 +92,6 @@ namespace gaseous_server.Classes
|
|||||||
dbDict.Add("id", RomId);
|
dbDict.Add("id", RomId);
|
||||||
db.ExecuteCMD(sql, dbDict);
|
db.ExecuteCMD(sql, dbDict);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static GameRomItem BuildRom(DataRow romDR)
|
private static GameRomItem BuildRom(DataRow romDR)
|
||||||
{
|
{
|
||||||
@@ -116,8 +113,7 @@ namespace gaseous_server.Classes
|
|||||||
MediaLabel = (string)romDR["medialabel"],
|
MediaLabel = (string)romDR["medialabel"],
|
||||||
Path = (string)romDR["path"],
|
Path = (string)romDR["path"],
|
||||||
Source = (gaseous_signature_parser.models.RomSignatureObject.RomSignatureObject.Game.Rom.SignatureSourceType)(Int32)romDR["metadatasource"],
|
Source = (gaseous_signature_parser.models.RomSignatureObject.RomSignatureObject.Game.Rom.SignatureSourceType)(Int32)romDR["metadatasource"],
|
||||||
SignatureSourceGameTitle = (string)Common.ReturnValueIfNull(romDR["MetadataGameName"], ""),
|
SignatureSourceGameTitle = (string)Common.ReturnValueIfNull(romDR["MetadataGameName"], "")
|
||||||
Library = GameLibrary.GetLibrary((int)romDR["LibraryId"])
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// check for a web emulator and update the romItem
|
// check for a web emulator and update the romItem
|
||||||
@@ -157,7 +153,6 @@ namespace gaseous_server.Classes
|
|||||||
public string? Path { get; set; }
|
public string? Path { get; set; }
|
||||||
public gaseous_signature_parser.models.RomSignatureObject.RomSignatureObject.Game.Rom.SignatureSourceType Source { get; set; }
|
public gaseous_signature_parser.models.RomSignatureObject.RomSignatureObject.Game.Rom.SignatureSourceType Source { get; set; }
|
||||||
public string? SignatureSourceGameTitle { get; set;}
|
public string? SignatureSourceGameTitle { get; set;}
|
||||||
public GameLibrary.LibraryItem Library { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -212,13 +212,12 @@ namespace gaseous_server.SignatureIngestors.XML
|
|||||||
dbDict.Add("romtypemedia", Common.ReturnValueIfNull(romObject.RomTypeMedia, ""));
|
dbDict.Add("romtypemedia", Common.ReturnValueIfNull(romObject.RomTypeMedia, ""));
|
||||||
dbDict.Add("medialabel", Common.ReturnValueIfNull(romObject.MediaLabel, ""));
|
dbDict.Add("medialabel", Common.ReturnValueIfNull(romObject.MediaLabel, ""));
|
||||||
dbDict.Add("metadatasource", romObject.SignatureSource);
|
dbDict.Add("metadatasource", romObject.SignatureSource);
|
||||||
dbDict.Add("ingestorversion", 2);
|
|
||||||
|
|
||||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||||
if (sigDB.Rows.Count == 0)
|
if (sigDB.Rows.Count == 0)
|
||||||
{
|
{
|
||||||
// entry not present, insert it
|
// entry not present, insert it
|
||||||
sql = "INSERT INTO Signatures_Roms (GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Attributes, RomType, RomTypeMedia, MediaLabel, MetadataSource, IngestorVersion) VALUES (@gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @attributes, @romtype, @romtypemedia, @medialabel, @metadatasource, @ingestorversion); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
sql = "INSERT INTO Signatures_Roms (GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Attributes, RomType, RomTypeMedia, MediaLabel, MetadataSource) VALUES (@gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @attributes, @romtype, @romtypemedia, @medialabel, @metadatasource); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,77 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace gaseous_server.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/v1/[controller]")]
|
|
||||||
public class LibraryController : Controller
|
|
||||||
{
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(typeof(List<GameLibrary.LibraryItem>), StatusCodes.Status200OK)]
|
|
||||||
public ActionResult GetLibraries()
|
|
||||||
{
|
|
||||||
return Ok(GameLibrary.GetLibraries);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{LibraryId}")]
|
|
||||||
[ProducesResponseType(typeof(GameLibrary.LibraryItem), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
public ActionResult GetLibrary(int LibraryId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Ok(GameLibrary.GetLibrary(LibraryId));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
[ProducesResponseType(typeof(GameLibrary.LibraryItem), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
|
||||||
public ActionResult AddLibrary(string Name, string Path, long DefaultPlatformId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Ok(GameLibrary.AddLibrary(Name, Path, DefaultPlatformId));
|
|
||||||
}
|
|
||||||
catch (GameLibrary.PathExists exPE)
|
|
||||||
{
|
|
||||||
return Conflict("Path already used in another library");
|
|
||||||
}
|
|
||||||
catch (GameLibrary.PathNotFound exPNF)
|
|
||||||
{
|
|
||||||
return NotFound("Path not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpDelete("{LibraryId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
public ActionResult DelLibrary(int LibraryId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GameLibrary.DeleteLibrary(LibraryId);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
catch (GameLibrary.CannotDeleteDefaultLibrary exCDDL)
|
|
||||||
{
|
|
||||||
return BadRequest(exCDDL.ToString());
|
|
||||||
}
|
|
||||||
catch (GameLibrary.LibraryNotFound exLNF)
|
|
||||||
{
|
|
||||||
return NotFound(exLNF.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -24,10 +24,8 @@ namespace gaseous_server.Controllers
|
|||||||
|
|
||||||
// disk size
|
// disk size
|
||||||
List<SystemInfo.PathItem> Disks = new List<SystemInfo.PathItem>();
|
List<SystemInfo.PathItem> Disks = new List<SystemInfo.PathItem>();
|
||||||
foreach (GameLibrary.LibraryItem libraryItem in GameLibrary.GetLibraries)
|
//Disks.Add(GetDisk(gaseous_tools.Config.ConfigurationPath));
|
||||||
{
|
Disks.Add(GetDisk(gaseous_tools.Config.LibraryConfiguration.LibraryRootDirectory));
|
||||||
Disks.Add(GetDisk(libraryItem.Path));
|
|
||||||
}
|
|
||||||
ReturnValue.Paths = Disks;
|
ReturnValue.Paths = Disks;
|
||||||
|
|
||||||
// database size
|
// database size
|
||||||
|
@@ -15,6 +15,8 @@ namespace gaseous_server.Models
|
|||||||
{
|
{
|
||||||
public class PlatformMapping
|
public class PlatformMapping
|
||||||
{
|
{
|
||||||
|
private static Dictionary<string, PlatformMapItem> PlatformMapCache = new Dictionary<string, PlatformMapItem>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the platform map from the embedded platform map resource
|
/// Updates the platform map from the embedded platform map resource
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -97,9 +99,17 @@ namespace gaseous_server.Models
|
|||||||
|
|
||||||
List<PlatformMapItem> platformMaps = new List<PlatformMapItem>();
|
List<PlatformMapItem> platformMaps = new List<PlatformMapItem>();
|
||||||
foreach (DataRow row in data.Rows)
|
foreach (DataRow row in data.Rows)
|
||||||
|
{
|
||||||
|
long mapId = (long)row["Id"];
|
||||||
|
if (PlatformMapCache.ContainsKey(mapId.ToString()))
|
||||||
|
{
|
||||||
|
platformMaps.Add(PlatformMapCache[mapId.ToString()]);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
platformMaps.Add(BuildPlatformMapItem(row));
|
platformMaps.Add(BuildPlatformMapItem(row));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
platformMaps.Sort((x, y) => x.IGDBName.CompareTo(y.IGDBName));
|
platformMaps.Sort((x, y) => x.IGDBName.CompareTo(y.IGDBName));
|
||||||
|
|
||||||
@@ -108,6 +118,12 @@ namespace gaseous_server.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static PlatformMapItem GetPlatformMap(long Id)
|
public static PlatformMapItem GetPlatformMap(long Id)
|
||||||
|
{
|
||||||
|
if (PlatformMapCache.ContainsKey(Id.ToString()))
|
||||||
|
{
|
||||||
|
return PlatformMapCache[Id.ToString()];
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
string sql = "SELECT * FROM PlatformMap WHERE Id = @Id";
|
string sql = "SELECT * FROM PlatformMap WHERE Id = @Id";
|
||||||
@@ -128,6 +144,7 @@ namespace gaseous_server.Models
|
|||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void WritePlatformMap(PlatformMapItem item, bool Update, bool AllowAvailableEmulatorOverwrite)
|
public static void WritePlatformMap(PlatformMapItem item, bool Update, bool AllowAvailableEmulatorOverwrite)
|
||||||
{
|
{
|
||||||
@@ -218,6 +235,11 @@ namespace gaseous_server.Models
|
|||||||
db.ExecuteCMD(sql, dbDict);
|
db.ExecuteCMD(sql, dbDict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PlatformMapCache.ContainsKey(item.IGDBId.ToString()))
|
||||||
|
{
|
||||||
|
PlatformMapCache.Remove(item.IGDBId.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PlatformMapItem BuildPlatformMapItem(DataRow row)
|
static PlatformMapItem BuildPlatformMapItem(DataRow row)
|
||||||
@@ -321,6 +343,15 @@ namespace gaseous_server.Models
|
|||||||
};
|
};
|
||||||
mapItem.Bios = bioss;
|
mapItem.Bios = bioss;
|
||||||
|
|
||||||
|
if (PlatformMapCache.ContainsKey(IGDBId.ToString()))
|
||||||
|
{
|
||||||
|
PlatformMapCache[IGDBId.ToString()] = mapItem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlatformMapCache.Add(IGDBId.ToString(), mapItem);
|
||||||
|
}
|
||||||
|
|
||||||
return mapItem;
|
return mapItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,24 +12,8 @@ using Microsoft.OpenApi.Models;
|
|||||||
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);
|
||||||
|
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
|
|
||||||
// check db availability
|
|
||||||
bool dbOnline = false;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Logging.Log(Logging.LogType.Information, "Startup", "Waiting for database...");
|
|
||||||
if (db.TestConnection() == true)
|
|
||||||
{
|
|
||||||
dbOnline = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread.Sleep(30000);
|
|
||||||
}
|
|
||||||
} while (dbOnline == true);
|
|
||||||
|
|
||||||
// set up db
|
// set up db
|
||||||
|
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
db.InitDB();
|
db.InitDB();
|
||||||
|
|
||||||
// load app settings
|
// load app settings
|
||||||
@@ -198,9 +182,8 @@ ProcessQueue.QueueItems.Add(new ProcessQueue.QueueItem(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
ProcessQueue.QueueItems.Add(new ProcessQueue.QueueItem(
|
ProcessQueue.QueueItems.Add(new ProcessQueue.QueueItem(
|
||||||
ProcessQueue.QueueItemType.LibraryScan, 30, new List<ProcessQueue.QueueItemType>
|
ProcessQueue.QueueItemType.LibraryScan, 1440, new List<ProcessQueue.QueueItemType>
|
||||||
{
|
{
|
||||||
ProcessQueue.QueueItemType.TitleIngestor,
|
|
||||||
ProcessQueue.QueueItemType.OrganiseLibrary
|
ProcessQueue.QueueItemType.OrganiseLibrary
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@@ -120,20 +120,8 @@
|
|||||||
},
|
},
|
||||||
"retroPieDirectoryName": "amiga",
|
"retroPieDirectoryName": "amiga",
|
||||||
"webEmulator": {
|
"webEmulator": {
|
||||||
"type": "EmulatorJS",
|
"type": "",
|
||||||
"core": "amiga",
|
"core": ""
|
||||||
"availableWebEmulators": [
|
|
||||||
{
|
|
||||||
"emulatorType": "EmulatorJS",
|
|
||||||
"availableWebEmulatorCores": [
|
|
||||||
{
|
|
||||||
"core": "amiga",
|
|
||||||
"alternateCoreName": "puae",
|
|
||||||
"default": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"bios": [
|
"bios": [
|
||||||
{
|
{
|
||||||
@@ -582,20 +570,8 @@
|
|||||||
},
|
},
|
||||||
"retroPieDirectoryName": "c64",
|
"retroPieDirectoryName": "c64",
|
||||||
"webEmulator": {
|
"webEmulator": {
|
||||||
"type": "EmulatorJS",
|
"type": "",
|
||||||
"core": "vice_x64",
|
"core": ""
|
||||||
"availableWebEmulators": [
|
|
||||||
{
|
|
||||||
"emulatorType": "EmulatorJS",
|
|
||||||
"availableWebEmulatorCores": [
|
|
||||||
{
|
|
||||||
"core": "c64",
|
|
||||||
"alternateCoreName": "vice_x64",
|
|
||||||
"default": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"bios": [
|
"bios": [
|
||||||
{
|
{
|
||||||
|
@@ -80,7 +80,7 @@ namespace gaseous_server
|
|||||||
qi.Blocks.Contains(ProcessQueue.QueueItemType.All)
|
qi.Blocks.Contains(ProcessQueue.QueueItemType.All)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//Console.WriteLine(queueItem.ItemType.ToString() + " is blocked by " + qi.ItemType.ToString());
|
Console.WriteLine(queueItem.ItemType.ToString() + " is blocked by " + qi.ItemType.ToString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Submodule gaseous-server/wwwroot/emulators/EmulatorJS updated: 921f7a01c6...23dd44825f
@@ -1,27 +0,0 @@
|
|||||||
<p>Are you sure you want to delete this library?</p>
|
|
||||||
<p><strong>Warning:</strong> This cannot be undone!</p>
|
|
||||||
<div style="width: 100%; text-align: center;">
|
|
||||||
<div style="display: inline-block; margin-right: 20px;">
|
|
||||||
<button class="redbutton" value="Delete" onclick="deleteLibrary();">Delete</button>
|
|
||||||
</div>
|
|
||||||
<div style="display: inline-block; margin-left: 20px;">
|
|
||||||
<button value="Cancel" onclick="closeSubDialog();">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function deleteLibrary() {
|
|
||||||
ajaxCall(
|
|
||||||
'/api/v1/Library/' + subModalVariables,
|
|
||||||
'DELETE',
|
|
||||||
function (result) {
|
|
||||||
drawLibrary();
|
|
||||||
closeSubDialog();
|
|
||||||
},
|
|
||||||
function (error) {
|
|
||||||
drawLibrary();
|
|
||||||
closeSubDialog();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,91 +0,0 @@
|
|||||||
<div style="padding-top: 5px;">
|
|
||||||
<strong>New Library</strong>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="width: 300px;">
|
|
||||||
<table style="width: 98%; margin-top: 15px; margin-bottom: 15px;">
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<td><input type="text" id="newlibrary_name" style="width: 95%;" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Default Platform</th>
|
|
||||||
<td><select id="newlibrary_defaultplatform" style="width: 100%;"></select></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Path</th>
|
|
||||||
<td><input type="text" id="newlibrary_path" style="width: 95%;" /></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div style="width: 100%; text-align: right;">
|
|
||||||
<div style="display: inline-block; margin-right: 20px;">
|
|
||||||
<button value="OK" onclick="newLibrary();">OK</button>
|
|
||||||
</div>
|
|
||||||
<div style="display: inline-block;">
|
|
||||||
<button value="Cancel" onclick="closeSubDialog();">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$('#newlibrary_defaultplatform').select2({
|
|
||||||
minimumInputLength: 3,
|
|
||||||
ajax: {
|
|
||||||
url: '/api/v1/Search/Platform',
|
|
||||||
data: function (params) {
|
|
||||||
var query = {
|
|
||||||
SearchString: params.term
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query parameters will be ?SearchString=[term]
|
|
||||||
return query;
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
var arr = [];
|
|
||||||
|
|
||||||
arr.push({
|
|
||||||
id: 0,
|
|
||||||
text: 'Any'
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
|
||||||
arr.push({
|
|
||||||
id: data[i].id,
|
|
||||||
text: data[i].name
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
results: arr
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
document.getElementById('newlibrary_defaultplatform').innerHTML = "<option value='" + 0 + "' selected='selected'>Any</option>";
|
|
||||||
|
|
||||||
function newLibrary() {
|
|
||||||
var libName = document.getElementById('newlibrary_name').value;
|
|
||||||
var libPlatform = $('#newlibrary_defaultplatform').select2('data');
|
|
||||||
var libPath = document.getElementById('newlibrary_path').value;
|
|
||||||
|
|
||||||
if (libName.length == 0) {
|
|
||||||
alert("A library name must be provided.")
|
|
||||||
} else if (libPath.length == 0) {
|
|
||||||
alert("A path must be provided.");
|
|
||||||
} else {
|
|
||||||
ajaxCall(
|
|
||||||
'/api/v1/Library?Name=' + encodeURIComponent(libName) + '&DefaultPlatformId=' + libPlatform[0].id + '&Path=' + encodeURIComponent(libPath),
|
|
||||||
'POST',
|
|
||||||
function(result) {
|
|
||||||
drawLibrary();
|
|
||||||
closeSubDialog();
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
alert('An error occurred while creating the library:\n\n' + JSON.stringify(error.responseText));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -7,10 +7,6 @@
|
|||||||
<div id="properties_bodypanel">
|
<div id="properties_bodypanel">
|
||||||
<div id="properties_bodypanel_general" name="properties_tab" style="display: none;">
|
<div id="properties_bodypanel_general" name="properties_tab" style="display: none;">
|
||||||
<table cellspacing="0" style="width: 100%;">
|
<table cellspacing="0" style="width: 100%;">
|
||||||
<tr>
|
|
||||||
<th>Library</th>
|
|
||||||
<td id="rominfo_library"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Platform</th>
|
<th>Platform</th>
|
||||||
<td id="rominfo_platform"></td>
|
<td id="rominfo_platform"></td>
|
||||||
@@ -121,7 +117,6 @@
|
|||||||
ajaxCall('/api/v1/Games/' + gameId + '/roms/' + modalVariables, 'GET', function (result) {
|
ajaxCall('/api/v1/Games/' + gameId + '/roms/' + modalVariables, 'GET', function (result) {
|
||||||
romData = result;
|
romData = result;
|
||||||
document.getElementById('modal-heading').innerHTML = result.name;
|
document.getElementById('modal-heading').innerHTML = result.name;
|
||||||
document.getElementById('rominfo_library').innerHTML = result.library.name;
|
|
||||||
document.getElementById('rominfo_platform').innerHTML = result.platform.name;
|
document.getElementById('rominfo_platform').innerHTML = result.platform.name;
|
||||||
document.getElementById('rominfo_size').innerHTML = formatBytes(result.size, 2);
|
document.getElementById('rominfo_size').innerHTML = formatBytes(result.size, 2);
|
||||||
document.getElementById('rominfo_type').innerHTML = getRomType(result.romType);
|
document.getElementById('rominfo_type').innerHTML = getRomType(result.romType);
|
||||||
@@ -135,10 +130,6 @@
|
|||||||
document.getElementById('properties_fixplatform').innerHTML = "<option value='" + result.platform.id + "' selected='selected'>" + result.platform.name + "</option>";
|
document.getElementById('properties_fixplatform').innerHTML = "<option value='" + result.platform.id + "' selected='selected'>" + result.platform.name + "</option>";
|
||||||
document.getElementById('properties_fixgame').innerHTML = "<option value='" + gameData.id + "' selected='selected'>" + gameData.name + "</option>";
|
document.getElementById('properties_fixgame').innerHTML = "<option value='" + gameData.id + "' selected='selected'>" + gameData.name + "</option>";
|
||||||
|
|
||||||
if (result.library.isDefaultLibrary == false) {
|
|
||||||
document.getElementById('romDelete').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.attributes.length > 0) {
|
if (result.attributes.length > 0) {
|
||||||
document.getElementById('properties_bodypanel_attributes').appendChild(BuildAttributesTable(result.attributes, result.source));
|
document.getElementById('properties_bodypanel_attributes').appendChild(BuildAttributesTable(result.attributes, result.source));
|
||||||
} else {
|
} else {
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
<div id="properties_toc" class="settings_toc">
|
<div id="properties_toc" class="settings_toc">
|
||||||
<div class="filter_header">Settings</div>
|
<div class="filter_header">Settings</div>
|
||||||
<div id="properties_toc_system" name="properties_toc_item" onclick="SelectTab('system');">System</div>
|
<div id="properties_toc_system" name="properties_toc_item" onclick="SelectTab('system');">System</div>
|
||||||
<div id="properties_toc_settings" name="properties_toc_item" onclick="SelectTab('settings');">Settings</div>
|
|
||||||
<div id="properties_toc_mapping" name="properties_toc_item" onclick="SelectTab('mapping');">Platform Mapping</div>
|
<div id="properties_toc_mapping" name="properties_toc_item" onclick="SelectTab('mapping');">Platform Mapping</div>
|
||||||
<div id="properties_toc_bios" name="properties_toc_item" onclick="SelectTab('bios');">Firmware</div>
|
<div id="properties_toc_bios" name="properties_toc_item" onclick="SelectTab('bios');">Firmware</div>
|
||||||
<div id="properties_toc_logs" name="properties_toc_item" onclick="SelectTab('logs');">Logs</div>
|
<div id="properties_toc_logs" name="properties_toc_item" onclick="SelectTab('logs');">Logs</div>
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
<div id="gametitle">
|
|
||||||
<h1 id="gametitle_label">Settings</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Libraries</h3>
|
|
||||||
<table id="settings_libraries" class="romtable" style="width: 100%;" cellspacing="0">
|
|
||||||
|
|
||||||
</table>
|
|
||||||
<div style="text-align: right;"><button id="settings_newlibrary" onclick="showSubDialog('librarynew');">New Library</button></div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function drawLibrary() {
|
|
||||||
ajaxCall(
|
|
||||||
'/api/v1/Library',
|
|
||||||
'GET',
|
|
||||||
function (result) {
|
|
||||||
var newTable = document.getElementById('settings_libraries');
|
|
||||||
newTable.innerHTML = '';
|
|
||||||
newTable.appendChild(createTableRow(true, ['Name', 'Path', 'Default Platform', 'Default Library', '']));
|
|
||||||
|
|
||||||
for (var i = 0; i < result.length; i++) {
|
|
||||||
var platformName = '';
|
|
||||||
if (result[i].defaultPlatformId == 0) {
|
|
||||||
if (result[i].isDefaultLibrary == true) {
|
|
||||||
platformName = "n/a";
|
|
||||||
} else {
|
|
||||||
platformName = "";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
platformName = result[i].defaultPlatformName;
|
|
||||||
}
|
|
||||||
|
|
||||||
var defaultLibrary = '';
|
|
||||||
if (result[i].isDefaultLibrary == true) {
|
|
||||||
defaultLibrary = "Yes";
|
|
||||||
} else {
|
|
||||||
defaultLibrary = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
var deleteButton = '';
|
|
||||||
if (result[i].isDefaultLibrary == false) {
|
|
||||||
var deleteButton = '<a href="#" onclick="showSubDialog(\'librarydelete\', ' + result[i].id + ');" class="romlink"><img src="/images/delete.svg" class="banner_button_image" alt="Delete" title="Delete" /></a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
newTable.appendChild(createTableRow(
|
|
||||||
false,
|
|
||||||
[
|
|
||||||
result[i].name,
|
|
||||||
result[i].path,
|
|
||||||
platformName,
|
|
||||||
defaultLibrary,
|
|
||||||
'<div style="text-align: right;">' + deleteButton + '</div>'
|
|
||||||
],
|
|
||||||
'romrow',
|
|
||||||
'romcell'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawLibrary();
|
|
||||||
</script>
|
|
@@ -104,12 +104,6 @@ namespace gaseous_tools
|
|||||||
".DS_STORE",
|
".DS_STORE",
|
||||||
"desktop.ini"
|
"desktop.ini"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string NormalizePath(string path)
|
|
||||||
{
|
|
||||||
return Path.GetFullPath(new Uri(path).LocalPath)
|
|
||||||
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -183,7 +183,7 @@ namespace gaseous_tools
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
string sql = "SELECT Value FROM Settings WHERE Setting = @SettingName";
|
string sql = "SELECT * FROM Settings WHERE Setting = @SettingName";
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||||
dbDict.Add("SettingName", SettingName);
|
dbDict.Add("SettingName", SettingName);
|
||||||
dbDict.Add("Value", DefaultValue);
|
dbDict.Add("Value", DefaultValue);
|
||||||
@@ -337,13 +337,13 @@ namespace gaseous_tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public string LibraryDataDirectory
|
public string LibraryDataDirectory
|
||||||
// {
|
{
|
||||||
// get
|
get
|
||||||
// {
|
{
|
||||||
// return Path.Combine(LibraryRootDirectory, "Library");
|
return Path.Combine(LibraryRootDirectory, "Library");
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
public string LibraryBIOSDirectory
|
public string LibraryBIOSDirectory
|
||||||
{
|
{
|
||||||
@@ -418,6 +418,7 @@ namespace gaseous_tools
|
|||||||
{
|
{
|
||||||
if (!Directory.Exists(LibraryRootDirectory)) { Directory.CreateDirectory(LibraryRootDirectory); }
|
if (!Directory.Exists(LibraryRootDirectory)) { Directory.CreateDirectory(LibraryRootDirectory); }
|
||||||
if (!Directory.Exists(LibraryImportDirectory)) { Directory.CreateDirectory(LibraryImportDirectory); }
|
if (!Directory.Exists(LibraryImportDirectory)) { Directory.CreateDirectory(LibraryImportDirectory); }
|
||||||
|
if (!Directory.Exists(LibraryDataDirectory)) { Directory.CreateDirectory(LibraryDataDirectory); }
|
||||||
if (!Directory.Exists(LibraryBIOSDirectory)) { Directory.CreateDirectory(LibraryBIOSDirectory); }
|
if (!Directory.Exists(LibraryBIOSDirectory)) { Directory.CreateDirectory(LibraryBIOSDirectory); }
|
||||||
if (!Directory.Exists(LibraryUploadDirectory)) { Directory.CreateDirectory(LibraryUploadDirectory); }
|
if (!Directory.Exists(LibraryUploadDirectory)) { Directory.CreateDirectory(LibraryUploadDirectory); }
|
||||||
if (!Directory.Exists(LibraryMetadataDirectory)) { Directory.CreateDirectory(LibraryMetadataDirectory); }
|
if (!Directory.Exists(LibraryMetadataDirectory)) { Directory.CreateDirectory(LibraryMetadataDirectory); }
|
||||||
|
@@ -206,18 +206,6 @@ namespace gaseous_tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TestConnection()
|
|
||||||
{
|
|
||||||
switch (_ConnectorType)
|
|
||||||
{
|
|
||||||
case databaseType.MySql:
|
|
||||||
MySQLServerConnector conn = new MySQLServerConnector(_ConnectionString);
|
|
||||||
return conn.TestConnection();
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SQLTransactionItem
|
public class SQLTransactionItem
|
||||||
{
|
{
|
||||||
public SQLTransactionItem()
|
public SQLTransactionItem()
|
||||||
@@ -326,20 +314,6 @@ namespace gaseous_tools
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TestConnection()
|
|
||||||
{
|
|
||||||
MySqlConnection conn = new MySqlConnection(DBConn);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
conn.Close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
CREATE TABLE `GameLibraries` (
|
|
||||||
`Id` int NOT NULL AUTO_INCREMENT,
|
|
||||||
`Name` VARCHAR(255) NOT NULL,
|
|
||||||
`Path` longtext NOT NULL,
|
|
||||||
`DefaultLibrary` int NOT NULL DEFAULT '0',
|
|
||||||
`DefaultPlatform` bigint NOT NULL DEFAULT '0',
|
|
||||||
PRIMARY KEY (`Id`)
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE `Games_Roms`
|
|
||||||
ADD COLUMN `LibraryId` INT NULL DEFAULT 0 AFTER `MetadataVersion`;
|
|
@@ -14,9 +14,6 @@ namespace gaseous_tools
|
|||||||
|
|
||||||
public static void PostUpgradeScript(int TargetSchemaVersion, gaseous_tools.Database.databaseType? DatabaseType)
|
public static void PostUpgradeScript(int TargetSchemaVersion, gaseous_tools.Database.databaseType? DatabaseType)
|
||||||
{
|
{
|
||||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
|
||||||
|
|
||||||
switch(DatabaseType)
|
switch(DatabaseType)
|
||||||
{
|
{
|
||||||
case Database.databaseType.MySql:
|
case Database.databaseType.MySql:
|
||||||
@@ -26,26 +23,6 @@ namespace gaseous_tools
|
|||||||
// this is a safe background task
|
// this is a safe background task
|
||||||
BackgroundUpgradeTargetSchemaVersions.Add(1002);
|
BackgroundUpgradeTargetSchemaVersions.Add(1002);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1004:
|
|
||||||
// needs to run on start up
|
|
||||||
|
|
||||||
// copy root path to new libraries format
|
|
||||||
string oldRoot = Path.Combine(Config.LibraryConfiguration.LibraryRootDirectory, "Library");
|
|
||||||
string sql = "INSERT INTO GameLibraries (Name, Path, DefaultLibrary, DefaultPlatform) VALUES (@name, @path, @defaultlibrary, @defaultplatform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
|
||||||
dbDict.Add("name", "Default");
|
|
||||||
dbDict.Add("path", oldRoot);
|
|
||||||
dbDict.Add("defaultlibrary", 1);
|
|
||||||
dbDict.Add("defaultplatform", 0);
|
|
||||||
DataTable data = db.ExecuteCMD(sql, dbDict);
|
|
||||||
|
|
||||||
// apply the new library id to the existing roms
|
|
||||||
sql = "UPDATE Games_Roms SET LibraryId=@libraryid;";
|
|
||||||
dbDict.Clear();
|
|
||||||
dbDict.Add("libraryid", data.Rows[0][0]);
|
|
||||||
db.ExecuteCMD(sql, dbDict);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
<None Remove="Database\MySQL\gaseous-1001.sql" />
|
<None Remove="Database\MySQL\gaseous-1001.sql" />
|
||||||
<None Remove="Database\MySQL\gaseous-1002.sql" />
|
<None Remove="Database\MySQL\gaseous-1002.sql" />
|
||||||
<None Remove="Database\MySQL\gaseous-1003.sql" />
|
<None Remove="Database\MySQL\gaseous-1003.sql" />
|
||||||
<None Remove="Database\MySQL\gaseous-1004.sql" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Database\" />
|
<Folder Include="Database\" />
|
||||||
@@ -30,6 +29,5 @@
|
|||||||
<EmbeddedResource Include="Database\MySQL\gaseous-1001.sql" />
|
<EmbeddedResource Include="Database\MySQL\gaseous-1001.sql" />
|
||||||
<EmbeddedResource Include="Database\MySQL\gaseous-1002.sql" />
|
<EmbeddedResource Include="Database\MySQL\gaseous-1002.sql" />
|
||||||
<EmbeddedResource Include="Database\MySQL\gaseous-1003.sql" />
|
<EmbeddedResource Include="Database\MySQL\gaseous-1003.sql" />
|
||||||
<EmbeddedResource Include="Database\MySQL\gaseous-1004.sql" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Reference in New Issue
Block a user