Update improvements

Include NzbDrone.Update in mono/osx package
Do not ignore certificate warnings for services
Check hash before extracting update
New: Update support for Linux/OS X - see the wiki for more information
This commit is contained in:
Mark McDowall 2014-04-27 23:34:29 -07:00
parent 5c2f77339d
commit ef3777fccf
46 changed files with 588 additions and 255 deletions

View file

@ -11,6 +11,7 @@ using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Update;
namespace NzbDrone.Core.Configuration
@ -30,11 +31,13 @@ namespace NzbDrone.Core.Configuration
string Password { get; }
string LogLevel { get; }
string Branch { get; }
bool AutoUpdate { get; }
string ApiKey { get; }
bool Torrent { get; }
string SslCertHash { get; }
string UrlBase { get; }
Boolean UpdateAutomatically { get; }
UpdateMechanism UpdateMechanism { get; }
String UpdateScriptPath { get; }
}
public class ConfigFileProvider : IConfigFileProvider
@ -141,11 +144,6 @@ namespace NzbDrone.Core.Configuration
get { return GetValue("Branch", "master").ToLowerInvariant(); }
}
public bool AutoUpdate
{
get { return GetValueBoolean("AutoUpdate", false, persist: false); }
}
public string Username
{
get { return GetValue("Username", ""); }
@ -181,6 +179,21 @@ namespace NzbDrone.Core.Configuration
}
}
public bool UpdateAutomatically
{
get { return GetValueBoolean("UpdateAutomatically", false, false); }
}
public UpdateMechanism UpdateMechanism
{
get { return GetValueEnum("UpdateMechanism", UpdateMechanism.BuiltIn, false); }
}
public string UpdateScriptPath
{
get { return GetValue("UpdateScriptPath", "", false ); }
}
public int GetValueInt(string key, int defaultValue)
{
return Convert.ToInt32(GetValue(key, defaultValue));
@ -191,9 +204,9 @@ namespace NzbDrone.Core.Configuration
return Convert.ToBoolean(GetValue(key, defaultValue, persist));
}
public T GetValueEnum<T>(string key, T defaultValue)
public T GetValueEnum<T>(string key, T defaultValue, bool persist = true)
{
return (T)Enum.Parse(typeof(T), GetValue(key, defaultValue), true);
return (T)Enum.Parse(typeof(T), GetValue(key, defaultValue), persist);
}
public string GetValue(string key, object defaultValue, bool persist = true)
@ -210,7 +223,9 @@ namespace NzbDrone.Core.Configuration
var valueHolder = parentContainer.Descendants(key).ToList();
if (valueHolder.Count() == 1)
{
return valueHolder.First().Value.Trim();
}
//Save the value
if (persist)