Fixed: Handle Gazelle NullRef (#447)

pull/6/head
Qstick 6 years ago committed by GitHub
parent a9e59b7798
commit ef7d54a412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,9 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Indexers.Gazelle namespace NzbDrone.Core.Indexers.Gazelle
{ {
@ -74,5 +77,12 @@ namespace NzbDrone.Core.Indexers.Gazelle
return settings; return settings;
} }
protected override void Test(List<ValidationFailure> failures)
{
// Remove previous cookies when testing incase user or pwd change
_authCookieCache.Remove(Settings.BaseUrl.Trim().TrimEnd('/'));
base.Test(failures);
}
} }
} }

@ -1,5 +1,4 @@
using System; using System;
using Newtonsoft.Json;
using System.Collections.Generic; using System.Collections.Generic;
namespace NzbDrone.Core.Indexers.Gazelle namespace NzbDrone.Core.Indexers.Gazelle

@ -1,6 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using Newtonsoft.Json;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;

@ -116,19 +116,16 @@ namespace NzbDrone.Core.Indexers.Gazelle
var response = HttpClient.Execute(authLoginRequest); var response = HttpClient.Execute(authLoginRequest);
cookies = response.GetCookies(); cookies = response.GetCookies();
AuthCookieCache.Set(authKey, cookies, new TimeSpan(7, 0, 0, 0, 0)); // re-auth every 7 days
requestBuilder.SetCookies(cookies); AuthCookieCache.Set(authKey, cookies);
}
else
{
requestBuilder.SetCookies(cookies);
} }
var index = GetIndex(cookies); var index = GetIndex(cookies);
if (index.Status.IsNullOrWhiteSpace() || index.Status != "success") if (index == null || index.Status.IsNullOrWhiteSpace() || index.Status != "success")
{ {
Logger.Debug("Gazelle authentication failed."); Logger.Debug("Gazelle authentication failed.");
AuthCookieCache.Remove(authKey);
throw new Exception("Failed to authenticate with Gazelle."); throw new Exception("Failed to authenticate with Gazelle.");
} }

@ -1,7 +1,6 @@
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
using System.Text.RegularExpressions;
namespace NzbDrone.Core.Indexers.Gazelle namespace NzbDrone.Core.Indexers.Gazelle
{ {

Loading…
Cancel
Save