Update background task time scheduling to use server local time. Ensure that the TZ variable is passed to the container with the location of the server. (#268)
* Remove LastRun values during upgrade * Add timezone variable to docker-compose files * Release note update to include PR's labeled "note"
This commit is contained in:
4
.github/release.yml
vendored
4
.github/release.yml
vendored
@@ -5,8 +5,12 @@ changelog:
|
||||
- '*'
|
||||
exclude:
|
||||
labels:
|
||||
- note
|
||||
- bug
|
||||
- dependencies
|
||||
- title: Notes
|
||||
labels:
|
||||
- note
|
||||
- title: Bug Fixes
|
||||
labels:
|
||||
- bug
|
||||
|
@@ -14,6 +14,7 @@ services:
|
||||
volumes:
|
||||
- gs:/root/.gaseous-server
|
||||
environment:
|
||||
- TZ=Australia/Sydney
|
||||
- dbhost=gsdb
|
||||
- dbuser=root
|
||||
- dbpass=gaseous
|
||||
|
@@ -13,6 +13,7 @@ services:
|
||||
volumes:
|
||||
- gs:/root/.gaseous-server
|
||||
environment:
|
||||
- TZ=Australia/Sydney
|
||||
- dbhost=gsdb
|
||||
- dbuser=root
|
||||
- dbpass=gaseous
|
||||
|
@@ -14,6 +14,7 @@ services:
|
||||
volumes:
|
||||
- gs:/root/.gaseous-server
|
||||
environment:
|
||||
- TZ=Australia/Sydney
|
||||
- dbhost=gsdb
|
||||
- dbuser=root
|
||||
- dbpass=gaseous
|
||||
|
@@ -13,6 +13,7 @@ services:
|
||||
volumes:
|
||||
- gs:/root/.gaseous-server
|
||||
environment:
|
||||
- TZ=Australia/Sydney
|
||||
- dbhost=gsdb
|
||||
- dbuser=root
|
||||
- dbpass=gaseous
|
||||
|
@@ -172,76 +172,123 @@ namespace gaseous_server.Classes
|
||||
DataTable dbResponse = db.ExecuteCMD(sql);
|
||||
foreach (DataRow dataRow in dbResponse.Rows)
|
||||
{
|
||||
if (AppSettings.ContainsKey((string)dataRow["Setting"]))
|
||||
string SettingName = (string)dataRow["Setting"];
|
||||
|
||||
if (AppSettings.ContainsKey(SettingName))
|
||||
{
|
||||
if ((int)dataRow["ValueType"] == 0)
|
||||
AppSettings.Remove(SettingName);
|
||||
}
|
||||
|
||||
Logging.Log(Logging.LogType.Information, "Load Settings", "Loading setting " + SettingName + " from database");
|
||||
|
||||
try
|
||||
{
|
||||
switch ((int)dataRow["ValueType"])
|
||||
{
|
||||
AppSettings[(string)dataRow["Setting"]] = (string)dataRow["Value"];
|
||||
}
|
||||
else
|
||||
{
|
||||
AppSettings[(string)dataRow["Setting"]] = (DateTime)dataRow["ValueDate"];
|
||||
case 0:
|
||||
default:
|
||||
// value is a string
|
||||
AppSettings.Add(SettingName, dataRow["Value"]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// value is a datetime
|
||||
AppSettings.Add(SettingName, dataRow["ValueDate"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (InvalidCastException castEx)
|
||||
{
|
||||
if ((int)dataRow["ValueType"] == 0)
|
||||
Logging.Log(Logging.LogType.Warning, "Settings", "Exception when reading server setting " + SettingName + ". Resetting to default.", castEx);
|
||||
|
||||
// delete broken setting and return the default
|
||||
// this error is probably generated during an upgrade
|
||||
sql = "DELETE FROM Settings WHERE Setting = @SettingName";
|
||||
Dictionary<string, object> dbDict = new Dictionary<string, object>
|
||||
{
|
||||
AppSettings.Add((string)dataRow["Setting"], (string)dataRow["Value"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppSettings.Add((string)dataRow["Setting"], (DateTime)dataRow["ValueDate"]);
|
||||
}
|
||||
{ "SettingName", SettingName }
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Log(Logging.LogType.Critical, "Settings", "Exception when reading server setting " + SettingName + ".", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static T ReadSetting<T>(string SettingName, T DefaultValue)
|
||||
{
|
||||
if (AppSettings.ContainsKey(SettingName))
|
||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||
try
|
||||
{
|
||||
return (T)AppSettings[SettingName];
|
||||
if (AppSettings.ContainsKey(SettingName))
|
||||
{
|
||||
return (T)AppSettings[SettingName];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
string sql = "SELECT Value, ValueDate FROM Settings WHERE Setting = @SettingName";
|
||||
Dictionary<string, object> dbDict = new Dictionary<string, object>
|
||||
{
|
||||
{ "SettingName", SettingName }
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
Logging.Log(Logging.LogType.Debug, "Database", "Reading setting '" + SettingName + "'");
|
||||
DataTable dbResponse = db.ExecuteCMD(sql, dbDict);
|
||||
Type type = typeof(T);
|
||||
if (dbResponse.Rows.Count == 0)
|
||||
{
|
||||
// no value with that name stored - respond with the default value
|
||||
SetSetting<T>(SettingName, DefaultValue);
|
||||
return DefaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type.ToString() == "System.DateTime")
|
||||
{
|
||||
AppSettings.Add(SettingName, dbResponse.Rows[0]["ValueDate"]);
|
||||
return (T)dbResponse.Rows[0]["ValueDate"];
|
||||
}
|
||||
else
|
||||
{
|
||||
AppSettings.Add(SettingName, dbResponse.Rows[0]["Value"]);
|
||||
return (T)dbResponse.Rows[0]["Value"];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Log(Logging.LogType.Critical, "Database", "Failed reading setting " + SettingName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (InvalidCastException castEx)
|
||||
{
|
||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||
string sql = "SELECT Value, ValueDate FROM Settings WHERE Setting = @SettingName";
|
||||
Logging.Log(Logging.LogType.Warning, "Settings", "Exception when reading server setting " + SettingName + ". Resetting to default.", castEx);
|
||||
|
||||
// delete broken setting and return the default
|
||||
// this error is probably generated during an upgrade
|
||||
if (AppSettings.ContainsKey(SettingName))
|
||||
{
|
||||
AppSettings.Remove(SettingName);
|
||||
}
|
||||
|
||||
string sql = "DELETE FROM Settings WHERE Setting = @SettingName";
|
||||
Dictionary<string, object> dbDict = new Dictionary<string, object>
|
||||
{
|
||||
{ "SettingName", SettingName }
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
Logging.Log(Logging.LogType.Debug, "Database", "Reading setting '" + SettingName + "'");
|
||||
DataTable dbResponse = db.ExecuteCMD(sql, dbDict);
|
||||
Type type = typeof(T);
|
||||
if (dbResponse.Rows.Count == 0)
|
||||
{
|
||||
// no value with that name stored - respond with the default value
|
||||
SetSetting<T>(SettingName, DefaultValue);
|
||||
return DefaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type.ToString() == "System.DateTime")
|
||||
{
|
||||
AppSettings.Add(SettingName, dbResponse.Rows[0]["ValueDate"]);
|
||||
return (T)dbResponse.Rows[0]["ValueDate"];
|
||||
}
|
||||
else
|
||||
{
|
||||
AppSettings.Add(SettingName, dbResponse.Rows[0]["Value"]);
|
||||
return (T)dbResponse.Rows[0]["Value"];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Log(Logging.LogType.Critical, "Database", "Failed reading setting " + SettingName, ex);
|
||||
throw;
|
||||
}
|
||||
return DefaultValue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Log(Logging.LogType.Critical, "Settings", "Exception when reading server setting " + SettingName + ".", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@ namespace gaseous_server.Classes
|
||||
public static void PostUpgradeScript(int TargetSchemaVersion, Database.databaseType? DatabaseType)
|
||||
{
|
||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||
string sql = "";
|
||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||
|
||||
switch(DatabaseType)
|
||||
@@ -32,7 +33,7 @@ namespace gaseous_server.Classes
|
||||
|
||||
// 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);";
|
||||
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);
|
||||
@@ -46,6 +47,11 @@ namespace gaseous_server.Classes
|
||||
db.ExecuteCMD(sql, dbDict);
|
||||
break;
|
||||
|
||||
case 1016:
|
||||
// delete old format LastRun_* settings from settings table
|
||||
sql = "DELETE FROM Settings WHERE Setting LIKE 'LastRun_%';";
|
||||
db.ExecuteNonQuery(sql);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user