Create libraries based on external unmanaged directories (#147)
* Library management is now complete * Library functions complete * Added default platform support
This commit is contained in:
@@ -104,6 +104,12 @@ namespace gaseous_tools
|
||||
".DS_STORE",
|
||||
"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
|
||||
{
|
||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||
string sql = "SELECT * FROM Settings WHERE Setting = @SettingName";
|
||||
string sql = "SELECT Value FROM Settings WHERE Setting = @SettingName";
|
||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||
dbDict.Add("SettingName", SettingName);
|
||||
dbDict.Add("Value", DefaultValue);
|
||||
@@ -337,13 +337,13 @@ namespace gaseous_tools
|
||||
}
|
||||
}
|
||||
|
||||
public string LibraryDataDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(LibraryRootDirectory, "Library");
|
||||
}
|
||||
}
|
||||
// public string LibraryDataDirectory
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return Path.Combine(LibraryRootDirectory, "Library");
|
||||
// }
|
||||
// }
|
||||
|
||||
public string LibraryBIOSDirectory
|
||||
{
|
||||
@@ -418,7 +418,6 @@ namespace gaseous_tools
|
||||
{
|
||||
if (!Directory.Exists(LibraryRootDirectory)) { Directory.CreateDirectory(LibraryRootDirectory); }
|
||||
if (!Directory.Exists(LibraryImportDirectory)) { Directory.CreateDirectory(LibraryImportDirectory); }
|
||||
if (!Directory.Exists(LibraryDataDirectory)) { Directory.CreateDirectory(LibraryDataDirectory); }
|
||||
if (!Directory.Exists(LibraryBIOSDirectory)) { Directory.CreateDirectory(LibraryBIOSDirectory); }
|
||||
if (!Directory.Exists(LibraryUploadDirectory)) { Directory.CreateDirectory(LibraryUploadDirectory); }
|
||||
if (!Directory.Exists(LibraryMetadataDirectory)) { Directory.CreateDirectory(LibraryMetadataDirectory); }
|
||||
|
||||
11
gaseous-tools/Database/MySQL/gaseous-1004.sql
Normal file
11
gaseous-tools/Database/MySQL/gaseous-1004.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
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,6 +14,9 @@ namespace gaseous_tools
|
||||
|
||||
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)
|
||||
{
|
||||
case Database.databaseType.MySql:
|
||||
@@ -23,6 +26,26 @@ namespace gaseous_tools
|
||||
// this is a safe background task
|
||||
BackgroundUpgradeTargetSchemaVersions.Add(1002);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<None Remove="Database\MySQL\gaseous-1001.sql" />
|
||||
<None Remove="Database\MySQL\gaseous-1002.sql" />
|
||||
<None Remove="Database\MySQL\gaseous-1003.sql" />
|
||||
<None Remove="Database\MySQL\gaseous-1004.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Database\" />
|
||||
@@ -29,5 +30,6 @@
|
||||
<EmbeddedResource Include="Database\MySQL\gaseous-1001.sql" />
|
||||
<EmbeddedResource Include="Database\MySQL\gaseous-1002.sql" />
|
||||
<EmbeddedResource Include="Database\MySQL\gaseous-1003.sql" />
|
||||
<EmbeddedResource Include="Database\MySQL\gaseous-1004.sql" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user