mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Added some update APIs to check for updates and download and extract the update package.
Todo: apply updated, UI.
This commit is contained in:
parent
e5c4f34e0e
commit
8f9946eb63
31 changed files with 18597 additions and 95 deletions
|
@ -11,14 +11,14 @@ namespace NzbDrone.Core.Providers.Core
|
|||
{
|
||||
public class ConfigFileProvider
|
||||
{
|
||||
private string _configFile = Path.Combine(CentralDispatch.AppPath, "App_Data", "Config.xml");
|
||||
private string _configFile = Path.Combine(new EnviromentProvider().AppPath, "App_Data", "Config.xml");
|
||||
|
||||
public string ConfigFile
|
||||
{
|
||||
get { return _configFile; }
|
||||
set { _configFile = value; }
|
||||
}
|
||||
|
||||
|
||||
public virtual int Port
|
||||
{
|
||||
get { return GetValueInt("Port", 8989); }
|
||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Providers.Core
|
|||
}
|
||||
|
||||
var valueHolder = parentContainer.Descendants(key).ToList();
|
||||
|
||||
|
||||
if (valueHolder.Count() == 1)
|
||||
return valueHolder.First().Value;
|
||||
|
||||
|
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Providers.Core
|
|||
public virtual void CreateDefaultConfigFile()
|
||||
{
|
||||
//Create the config file here
|
||||
Directory.CreateDirectory(Path.Combine(CentralDispatch.AppPath, "App_Data"));
|
||||
Directory.CreateDirectory(Path.Combine(new EnviromentProvider().AppPath, "App_Data"));
|
||||
|
||||
if (!File.Exists(ConfigFile))
|
||||
{
|
||||
|
|
|
@ -305,6 +305,12 @@ namespace NzbDrone.Core.Providers.Core
|
|||
set { SetValue("XbmcPassword", value); }
|
||||
}
|
||||
|
||||
public virtual string UpdateUrl
|
||||
{
|
||||
get { return GetValue("UpdateUrl", @"http://update.nzbdrone.com/master/"); }
|
||||
set { SetValue("UpdateUrl", value); }
|
||||
}
|
||||
|
||||
private string GetValue(string key)
|
||||
{
|
||||
return GetValue(key, String.Empty);
|
||||
|
|
|
@ -2,11 +2,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Ionic.Zip;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
{
|
||||
public class DiskProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public virtual bool FolderExists(string path)
|
||||
{
|
||||
return Directory.Exists(path);
|
||||
|
@ -74,6 +78,18 @@ namespace NzbDrone.Core.Providers.Core
|
|||
Directory.Move(source, destination);
|
||||
}
|
||||
|
||||
public virtual void ExtractArchive(string compressedFile, string destination)
|
||||
{
|
||||
Logger.Trace("Extracting archive [{0}] to [{1}]", compressedFile, destination);
|
||||
|
||||
using (ZipFile zipFile = ZipFile.Read(compressedFile))
|
||||
{
|
||||
zipFile.ExtractAll(destination);
|
||||
}
|
||||
|
||||
Logger.Trace("Extraction complete.");
|
||||
}
|
||||
|
||||
public virtual void InheritFolderPermissions(string filename)
|
||||
{
|
||||
var fs = File.GetAccessControl(filename);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
@ -50,19 +51,29 @@ namespace NzbDrone.Core.Providers.Core
|
|||
return response.GetResponseStream();
|
||||
}
|
||||
|
||||
public virtual bool DownloadFile(string address, string fileName)
|
||||
public virtual void DownloadFile(string url, string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileInfo = new FileInfo(fileName);
|
||||
if (!fileInfo.Directory.Exists)
|
||||
{
|
||||
fileInfo.Directory.Create();
|
||||
}
|
||||
|
||||
Logger.Trace("Downloading [{0}] to [{1}]", url, fileName);
|
||||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
var webClient = new WebClient();
|
||||
webClient.DownloadFile(address, fileName);
|
||||
return true;
|
||||
webClient.DownloadFile(url, fileName);
|
||||
stopWatch.Stop();
|
||||
Logger.Trace("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed to get response from: {0}", address);
|
||||
Logger.Warn("Failed to get response from: {0}", url);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
return false;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue