Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Client Priority with matching ui.
- Loading branch information
Showing
11 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/NzbDrone.Core/Datastore/Migration/132_add_download_client_priority.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Data; | ||
using FluentMigrator; | ||
using NzbDrone.Core.Datastore.Migration.Framework; | ||
|
||
namespace NzbDrone.Core.Datastore.Migration | ||
{ | ||
[Migration(132)] | ||
public class add_download_client_priority : NzbDroneMigrationBase | ||
{ | ||
protected override void MainDbUpgrade() | ||
{ | ||
Alter.Table("DownloadClients").AddColumn("Priority").AsInt32().WithDefaultValue(1); | ||
Execute.WithConnection(InitPriorityForBackwardCompatibility); | ||
|
||
} | ||
|
||
private void InitPriorityForBackwardCompatibility(IDbConnection conn, IDbTransaction tran) | ||
{ | ||
using (var cmd = conn.CreateCommand()) | ||
{ | ||
cmd.Transaction = tran; | ||
cmd.CommandText = "SELECT Id FROM DownloadClients WHERE Enable = 1"; | ||
|
||
using (var reader = cmd.ExecuteReader()) | ||
{ | ||
int i = 1; | ||
while (reader.Read()) | ||
{ | ||
var id = reader.GetInt32(0); | ||
|
||
using (var updateCmd = conn.CreateCommand()) | ||
{ | ||
updateCmd.Transaction = tran; | ||
updateCmd.CommandText = "UPDATE DownloadClients SET Priority = ? WHERE Id = ?"; | ||
updateCmd.AddParameter(i++); | ||
updateCmd.AddParameter(id); | ||
|
||
updateCmd.ExecuteNonQuery(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters