Fixed: Inversion of defaults in CDH migration.

pull/4500/head
Taloth Saldono 3 years ago
parent c3837c9f7b
commit dab1834960

@ -37,8 +37,8 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = db.Query<DownloadClientDefinition158>("SELECT * FROM DownloadClients"); var items = db.Query<DownloadClientDefinition158>("SELECT * FROM DownloadClients");
items.Should().HaveCount(1); items.Should().HaveCount(1);
items.First().RemoveCompletedDownloads.Should().BeTrue(); items.First().RemoveCompletedDownloads.Should().BeFalse();
items.First().RemoveFailedDownloads.Should().BeFalse(); items.First().RemoveFailedDownloads.Should().BeTrue();
} }
[Test] [Test]
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
c.Insert.IntoTable("Config").Row(new c.Insert.IntoTable("Config").Row(new
{ {
Key = "removecompleteddownloads", Key = "removecompleteddownloads",
Value = "False" Value = "True"
}); });
c.Insert.IntoTable("DownloadClients").Row(new c.Insert.IntoTable("DownloadClients").Row(new
@ -71,8 +71,8 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = db.Query<DownloadClientDefinition158>("SELECT * FROM DownloadClients"); var items = db.Query<DownloadClientDefinition158>("SELECT * FROM DownloadClients");
items.Should().HaveCount(1); items.Should().HaveCount(1);
items.First().RemoveCompletedDownloads.Should().BeFalse(); items.First().RemoveCompletedDownloads.Should().BeTrue();
items.First().RemoveFailedDownloads.Should().BeFalse(); items.First().RemoveFailedDownloads.Should().BeTrue();
} }
[Test] [Test]
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
items.Should().HaveCount(1); items.Should().HaveCount(1);
items.First().RemoveCompletedDownloads.Should().BeFalse(); items.First().RemoveCompletedDownloads.Should().BeFalse();
items.First().RemoveFailedDownloads.Should().BeFalse(); items.First().RemoveFailedDownloads.Should().BeTrue();
} }
} }

@ -21,19 +21,19 @@ namespace NzbDrone.Core.Datastore.Migration
private void MoveRemoveSettings(IDbConnection conn, IDbTransaction tran) private void MoveRemoveSettings(IDbConnection conn, IDbTransaction tran)
{ {
var removeCompletedDownloads = true; var removeCompletedDownloads = false;
var removeFailedDownloads = false; var removeFailedDownloads = true;
using (var removeCompletedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removecompleteddownloads'")) using (var removeCompletedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removecompleteddownloads'"))
{ {
if ("False" == (removeCompletedDownloadsCmd.ExecuteScalar() as string)) if ("true" == (removeCompletedDownloadsCmd.ExecuteScalar() as string)?.ToLower())
removeCompletedDownloads = false; removeCompletedDownloads = true;
} }
using (var removeFailedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removefaileddownloads'")) using (var removeFailedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removefaileddownloads'"))
{ {
if ("True" == (removeFailedDownloadsCmd.ExecuteScalar() as string)) if ("false" == (removeFailedDownloadsCmd.ExecuteScalar() as string)?.ToLower())
removeFailedDownloads = true; removeFailedDownloads = false;
} }
using (var updateClientCmd = conn.CreateCommand(tran, $"UPDATE DownloadClients SET RemoveCompletedDownloads = (CASE WHEN Implementation IN (\"RTorrent\", \"Flood\") THEN 0 ELSE ? END), RemoveFailedDownloads = ?")) using (var updateClientCmd = conn.CreateCommand(tran, $"UPDATE DownloadClients SET RemoveCompletedDownloads = (CASE WHEN Implementation IN (\"RTorrent\", \"Flood\") THEN 0 ELSE ? END), RemoveFailedDownloads = ?"))

Loading…
Cancel
Save