mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 04:59:35 -07:00
Prevent XML error from blowing up integration test
This commit is contained in:
parent
33ebf1bf78
commit
6534efae18
1 changed files with 16 additions and 6 deletions
|
@ -100,18 +100,28 @@ namespace NzbDrone.Test.Common
|
||||||
private void SetApiKey()
|
private void SetApiKey()
|
||||||
{
|
{
|
||||||
var configFile = Path.Combine(AppData, "config.xml");
|
var configFile = Path.Combine(AppData, "config.xml");
|
||||||
|
var attempts = 0;
|
||||||
|
|
||||||
while (ApiKey == null)
|
while (ApiKey == null && attempts < 50)
|
||||||
{
|
{
|
||||||
if (File.Exists(configFile))
|
try
|
||||||
{
|
{
|
||||||
var apiKeyElement = XDocument.Load(configFile)
|
if (File.Exists(configFile))
|
||||||
.XPathSelectElement("Config/ApiKey");
|
|
||||||
if (apiKeyElement != null)
|
|
||||||
{
|
{
|
||||||
ApiKey = apiKeyElement.Value;
|
var apiKeyElement = XDocument.Load(configFile)
|
||||||
|
.XPathSelectElement("Config/ApiKey");
|
||||||
|
if (apiKeyElement != null)
|
||||||
|
{
|
||||||
|
ApiKey = apiKeyElement.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting API Key from XML file: " + ex.Message, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
attempts++;
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue