Fixed: Inversion of defaults in CDH migration.

This commit is contained in:
Taloth Saldono 2021-05-20 01:43:25 +02:00
parent c3837c9f7b
commit dab1834960
2 changed files with 12 additions and 12 deletions

View File

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

View File

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