mirror of https://github.com/Radarr/Radarr
Fixed: Urls missing from multiple indexers after latest nightly update.
This commit is contained in:
parent
a460e89a8d
commit
0a71aac56c
|
@ -0,0 +1,58 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using FluentMigrator;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(139)]
|
||||
public class consolidate_indexer_baseurl : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Execute.WithConnection(RenameUrlToBaseUrl);
|
||||
}
|
||||
|
||||
private void RenameUrlToBaseUrl(IDbConnection conn, IDbTransaction tran)
|
||||
{
|
||||
using (var cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.Transaction = tran;
|
||||
cmd.CommandText = "SELECT Id, Settings FROM Indexers WHERE ConfigContract IN ('NewznabSettings', 'TorznabSettings', 'IPTorrentsSettings', 'OmgwtfnzbsSettings', )";
|
||||
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var id = reader.GetInt32(0);
|
||||
var settings = reader.GetString(1);
|
||||
|
||||
if (settings.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
var jsonObject = Json.Deserialize<JObject>(settings);
|
||||
|
||||
if (jsonObject.Property("url") != null)
|
||||
{
|
||||
jsonObject.AddFirst(new JProperty("baseUrl", jsonObject["url"]));
|
||||
jsonObject.Remove("url");
|
||||
settings = jsonObject.ToJson();
|
||||
|
||||
using (var updateCmd = conn.CreateCommand())
|
||||
{
|
||||
updateCmd.Transaction = tran;
|
||||
updateCmd.CommandText = "UPDATE Indexers SET Settings = ? WHERE Id = ?";
|
||||
updateCmd.AddParameter(settings);
|
||||
updateCmd.AddParameter(id);
|
||||
updateCmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1291,6 +1291,7 @@
|
|||
<Compile Include="NetImport\Radarr\RadarrSettings.cs" />
|
||||
<Compile Include="MetadataSource\RadarrAPI\RadarrResources.cs" />
|
||||
<Compile Include="MetadataSource\RadarrAPI\RadarrAPIClient.cs" />
|
||||
<Compile Include="Datastore\Migration\139_fix_indexer_baseurl.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||
|
|
Loading…
Reference in New Issue