Allow user to specify any journal mode

Signed-off-by: gnattu <gnattuoc@me.com>
pull/11464/head
gnattu 7 months ago
parent b3ab3a2ff2
commit 52ae4e504b

@ -20,7 +20,7 @@ namespace Emby.Server.Implementations
{ PlaylistsAllowDuplicatesKey, bool.FalseString },
{ BindToUnixSocketKey, bool.FalseString },
{ SqliteCacheSizeKey, "20000" },
{ SqliteDisableWalKey, bool.FalseString }
{ SqliteJournalModeKey, "WAL" }
};
}
}

@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.Data
/// Gets the journal mode. <see href="https://www.sqlite.org/pragma.html#pragma_journal_mode" />.
/// </summary>
/// <value>The journal mode.</value>
protected virtual string JournalMode => _configuration.GetSqliteWalDisabled() ? "TRUNCATE" : "WAL";
protected virtual string JournalMode => _configuration.GetSqliteJournalMode();
/// <summary>
/// Gets the journal size limit. <see href="https://www.sqlite.org/pragma.html#pragma_journal_size_limit" />.

@ -65,9 +65,9 @@ namespace MediaBrowser.Controller.Extensions
public const string SqliteCacheSizeKey = "sqlite:cacheSize";
/// <summary>
/// Disable WAL journaling of sqlite.
/// SQLite journal mode.
/// </summary>
public const string SqliteDisableWalKey = "sqlite:disableWal";
public const string SqliteJournalModeKey = "sqlite:journalMode";
/// <summary>
/// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>.
@ -135,24 +135,14 @@ namespace MediaBrowser.Controller.Extensions
=> configuration.GetValue<int?>(SqliteCacheSizeKey);
/// <summary>
/// Gets whether WAL journaling disabled from the <see cref="IConfiguration" />.
/// Gets SQLite journal mode from the <see cref="IConfiguration" />.
/// </summary>
/// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>Whether WAL journaling disabled.</returns>
public static bool GetSqliteWalDisabled(this IConfiguration configuration)
/// <returns>SQLite journal mode.</returns>
public static string GetSqliteJournalMode(this IConfiguration configuration)
{
var disableSqliteWal = configuration.GetValue<string?>(SqliteDisableWalKey);
var disableWal = false;
if (disableSqliteWal is not null)
{
disableWal = disableSqliteWal.ToUpperInvariant() switch
{
"FALSE" or "NO" or "0" => false,
_ => true
};
}
return disableWal;
var journalMode = configuration.GetValue<string?>(SqliteJournalModeKey);
return journalMode is not null ? journalMode.ToUpperInvariant() : "WAL";
}
}
}

Loading…
Cancel
Save