add custom sqlite pragmas

through environment variable CUSTOMSQLITEOPTIONS_DUPLICATI
This commit is contained in:
gpatel-fr
2023-03-23 20:25:18 +01:00
parent 666b228103
commit fbbc78619e
@@ -142,6 +142,29 @@ namespace Duplicati.Library.SQLiteHelper
throw;
}
// set custom Sqlite options
var opts = Environment.GetEnvironmentVariable("CUSTOMSQLITEOPTIONS_DUPLICATI");
if (opts != null) {
var topts = opts.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries);
if (topts.Length > 0) {
using (var cmd = con.CreateCommand()) {
foreach (var opt in topts) {
Logging.Log.WriteVerboseMessage(LOGTAG, "CustomSQLiteOption", @"Setting custom SQLite option '{0}'.", opt);
try
{
cmd.CommandText = string.Format("pragma {0}", opt);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Logging.Log.WriteErrorMessage(LOGTAG, "CustomSQLiteOption", ex, @"Error setting custom SQLite option '{0}'.", opt);
}
}
}
}
}
return con;
}