1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-02-28 08:55:51 +00:00

Updated migration to enable completed download handling for new users (those with no drone factory configured)

This commit is contained in:
Taloth Saldono 2014-05-30 17:54:02 +02:00
parent 1a63b1caba
commit 68352e0340
2 changed files with 21 additions and 0 deletions

View file

@ -14,6 +14,8 @@ public class ConfigServiceFixture : DbTest<ConfigService, Config>
public void SetUp() public void SetUp()
{ {
Mocker.SetConstant<IConfigRepository>(Mocker.Resolve<ConfigRepository>()); Mocker.SetConstant<IConfigRepository>(Mocker.Resolve<ConfigRepository>());
Db.All<Config>().ForEach(Db.Delete);
} }
[Test] [Test]

View file

@ -16,11 +16,30 @@ public class download_client_import : NzbDroneMigrationBase
{ {
protected override void MainDbUpgrade() protected override void MainDbUpgrade()
{ {
Execute.WithConnection(EnableCompletedDownloadHandlingForNewUsers);
Execute.WithConnection(ConvertFolderSettings); Execute.WithConnection(ConvertFolderSettings);
Execute.WithConnection(AssociateImportedHistoryItems); Execute.WithConnection(AssociateImportedHistoryItems);
} }
private void EnableCompletedDownloadHandlingForNewUsers(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand cmd = conn.CreateCommand())
{
cmd.Transaction = tran;
cmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'downloadedepisodesfolder'";
var result = cmd.ExecuteScalar();
if (result == null)
{
cmd.CommandText = @"INSERT INTO Config (Key, Value) VALUES ('enablecompleteddownloadhandling', 'True')";
cmd.ExecuteNonQuery();
}
}
}
private void ConvertFolderSettings(IDbConnection conn, IDbTransaction tran) private void ConvertFolderSettings(IDbConnection conn, IDbTransaction tran)
{ {
using (IDbCommand downloadClientsCmd = conn.CreateCommand()) using (IDbCommand downloadClientsCmd = conn.CreateCommand())