diff --git a/src/NzbDrone.Api/Config/HostConfigResource.cs b/src/NzbDrone.Api/Config/HostConfigResource.cs index 5580e02ee..327b93bbc 100644 --- a/src/NzbDrone.Api/Config/HostConfigResource.cs +++ b/src/NzbDrone.Api/Config/HostConfigResource.cs @@ -20,7 +20,6 @@ namespace NzbDrone.Api.Config public string Password { get; set; } public string LogLevel { get; set; } public string ConsoleLogLevel { get; set; } - public DatabaseJournalType DatabaseJournalMode { get; set; } public string Branch { get; set; } public string ApiKey { get; set; } public string SslCertHash { get; set; } diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 1e660bdf1..9277c1221 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -185,7 +185,7 @@ namespace NzbDrone.Core.Configuration public string LogLevel => GetValue("LogLevel", "Info"); public string ConsoleLogLevel => GetValue("ConsoleLogLevel", string.Empty, persist: false); - public DatabaseJournalType DatabaseJournalMode => GetValueEnum("DatabaseJournalMode", DatabaseJournalType.Wal, persist: false); + public DatabaseJournalType DatabaseJournalMode => GetValueEnum("DatabaseJournalMode", DatabaseJournalType.Auto, persist: false); public string SslCertHash => GetValue("SslCertHash", ""); diff --git a/src/NzbDrone.Core/Datastore/ConnectionStringFactory.cs b/src/NzbDrone.Core/Datastore/ConnectionStringFactory.cs index abe408dfe..01468ea3d 100644 --- a/src/NzbDrone.Core/Datastore/ConnectionStringFactory.cs +++ b/src/NzbDrone.Core/Datastore/ConnectionStringFactory.cs @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Datastore connectionBuilder.JournalMode = GetJournalMode(dbPath); - if (connectionBuilder.JournalMode == SQLiteJournalModeEnum.Truncate) + if (OsInfo.IsOsx) { connectionBuilder.Add("Full FSync", true); } @@ -65,26 +65,36 @@ namespace NzbDrone.Core.Datastore private SQLiteJournalModeEnum GetJournalMode(string path) { - var driveType = _diskProvider.GetMount(path).DriveType; - - if (driveType == DriveType.Network || driveType == DriveType.Unknown) + if (_configFileProvider.DatabaseJournalMode != DatabaseJournalType.Auto) { - _logger.Debug("Network filesystem store for application data detected, disabling WAL mode for SQLite"); - return SQLiteJournalModeEnum.Truncate; - } - - if (_configFileProvider.DatabaseJournalMode != (DatabaseJournalType)SQLiteJournalModeEnum.Wal) - { - _logger.Debug("DatabaseJournalMode tag detected in config.xml, disabling WAL mode for SQLite"); - return SQLiteJournalModeEnum.Truncate; + _logger.Debug("Database journal mode overridden by config.xml, using {0} journal mode", _configFileProvider.DatabaseJournalMode); + return (SQLiteJournalModeEnum)_configFileProvider.DatabaseJournalMode; } if (OsInfo.IsOsx) { - _logger.Debug("macOS operating system detected, disabling WAL mode for SQLite"); + _logger.Debug("macOS operating system, using Truncate database journal mode"); return SQLiteJournalModeEnum.Truncate; } + var mount = _diskProvider.GetMount(path); + + if (mount == null) + { + _logger.Debug("Database {0} located on unknown filesystem, using Truncate journal mode", path); + return SQLiteJournalModeEnum.Truncate; + } + + if (mount.DriveType == DriveType.Network || mount.DriveType == DriveType.Unknown) + { + _logger.Debug("Database {0} located on filesystem {1} with type {2}, using Truncate journal mode", path, mount.DriveFormat, mount.DriveType); + return SQLiteJournalModeEnum.Truncate; + } + else + { + _logger.Debug("Database {0} located on filesystem {1} with type {2}, using WAL journal mode", path, mount.DriveFormat, mount.DriveType); + } + return SQLiteJournalModeEnum.Wal; } } diff --git a/src/NzbDrone.Core/Datastore/DatabaseJournalType.cs b/src/NzbDrone.Core/Datastore/DatabaseJournalType.cs index 94a7fec8d..b38ed50ae 100644 --- a/src/NzbDrone.Core/Datastore/DatabaseJournalType.cs +++ b/src/NzbDrone.Core/Datastore/DatabaseJournalType.cs @@ -4,7 +4,9 @@ namespace NzbDrone.Core.Datastore { public enum DatabaseJournalType { + Auto = SQLiteJournalModeEnum.Default, Wal = SQLiteJournalModeEnum.Wal, - Truncate = SQLiteJournalModeEnum.Truncate + Truncate = SQLiteJournalModeEnum.Truncate, + Delete = SQLiteJournalModeEnum.Delete } } diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 9e2475c9e..62e8a88db 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -136,6 +136,7 @@ + diff --git a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs index 88e834d8a..9b53b5b87 100644 --- a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs +++ b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Mono.Disk public class ProcMountProvider : IProcMountProvider { private static string[] _fixedTypes = new [] { "ext3", "ext2", "ext4", "vfat", "fuseblk", "xfs", "jfs", "msdos", "ntfs", "minix", "hfs", "hfsplus", "qnx4", "ufs", "btrfs" }; - private static string[] _networkDriveTypes = new [] { "cifs", "nfs", "nfs4", "nfsd", "sshfs" }; + private static string[] _networkDriveTypes = new [] { "cifs", "nfs", "nfs4", "nfsd", "sshfs", "9p" }; private static readonly Regex OctalRegex = new Regex(@"\\\d{3}", RegexOptions.Compiled); private const string PROC_MOUNTS_FILENAME = @"/proc/mounts";