diff --git a/NzbDrone.Common/DiskProvider.cs b/NzbDrone.Common/DiskProvider.cs
index a26f03a28..902f4b57f 100644
--- a/NzbDrone.Common/DiskProvider.cs
+++ b/NzbDrone.Common/DiskProvider.cs
@@ -170,5 +170,10 @@ public virtual ulong FreeDiskSpace(DirectoryInfo directoryInfo)
return freeBytesAvailable;
}
+
+ public virtual string ReadAllText(string filePath)
+ {
+ return File.ReadAllText(filePath);
+ }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index e9739c412..d86f0e089 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -97,6 +97,7 @@
+
diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetUpdateLogFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetUpdateLogFixture.cs
new file mode 100644
index 000000000..7b7a44875
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetUpdateLogFixture.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Common;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Test.Framework;
+
+namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
+{
+ class GetUpdateLogFixture : CoreTest
+ {
+ String UpdateLogFolder;
+
+
+ [SetUp]
+ public void setup()
+ {
+ WithTempAsAppPath();
+
+ UpdateLogFolder = Mocker.GetMock().Object.GetUpdateLogFolder();
+
+ Mocker.GetMock()
+ .Setup(c => c.GetFiles(UpdateLogFolder, SearchOption.TopDirectoryOnly))
+ .Returns(new List
+ {
+ "C:\\nzbdrone\\update\\2011.09.20-19-08.txt",
+ "C:\\nzbdrone\\update\\2011.10.20-20-08.txt",
+ "C:\\nzbdrone\\update\\2011.12.20-21-08.txt"
+ });
+
+ Mocker.GetMock()
+ .Setup(c => c.FolderExists(UpdateLogFolder))
+ .Returns(true);
+ }
+
+
+ [Test]
+ public void get_logs_should_return_empty_list_if_directory_doesnt_exist()
+ {
+ Mocker.GetMock()
+ .Setup(c => c.FolderExists(UpdateLogFolder))
+ .Returns(false);
+
+ var logs = Mocker.Resolve().UpdateLogFile();
+ logs.Should().BeEmpty();
+ }
+
+
+ [Test]
+ public void get_logs_should_return_list_of_files_in_log_folder()
+ {
+ var logs = Mocker.Resolve().UpdateLogFile();
+ logs.Should().HaveCount(3);
+ }
+
+ }
+}
diff --git a/NzbDrone.Core/Providers/UpdateProvider.cs b/NzbDrone.Core/Providers/UpdateProvider.cs
index 040a689b6..20aab14b6 100644
--- a/NzbDrone.Core/Providers/UpdateProvider.cs
+++ b/NzbDrone.Core/Providers/UpdateProvider.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@@ -17,10 +18,8 @@ public class UpdateProvider
{
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
- private readonly ConfigFileProvider _configFileProvider;
private readonly EnviromentProvider _enviromentProvider;
- private readonly ArchiveProvider _archiveProvider;
- private readonly ProcessProvider _processProvider;
+
private readonly DiskProvider _diskProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
@@ -29,15 +28,12 @@ public class UpdateProvider
[Inject]
- public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider, ConfigFileProvider configFileProvider,
- EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider, ProcessProvider processProvider, DiskProvider diskProvider)
+ public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
+ EnviromentProvider enviromentProvider, DiskProvider diskProvider)
{
_httpProvider = httpProvider;
_configProvider = configProvider;
- _configFileProvider = configFileProvider;
_enviromentProvider = enviromentProvider;
- _archiveProvider = archiveProvider;
- _processProvider = processProvider;
_diskProvider = diskProvider;
}
@@ -77,5 +73,23 @@ public virtual UpdatePackage GetAvilableUpdate()
logger.Trace("No updates available");
return null;
}
+
+ public virtual Dictionary UpdateLogFile()
+ {
+ var list = new Dictionary();
+ CultureInfo provider = CultureInfo.InvariantCulture;
+
+ if (_diskProvider.FolderExists(_enviromentProvider.GetUpdateLogFolder()))
+ {
+ var files = _diskProvider.GetFiles(_enviromentProvider.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly).ToList();
+
+ foreach (var file in files.Select(c => new FileInfo(c)).OrderByDescending(c=>c.Name))
+ {
+ list.Add(DateTime.ParseExact(file.Name.Replace(file.Extension, string.Empty), "yyyy.MM.dd-H-mm", provider), file.FullName);
+ }
+ }
+
+ return list;
+ }
}
}
diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs
index 52049652d..306697dda 100644
--- a/NzbDrone.Test.Common/TestBase.cs
+++ b/NzbDrone.Test.Common/TestBase.cs
@@ -43,7 +43,7 @@ public void TestBaseSetup()
[TearDown]
public void TestBaseTearDown()
{
- Mocker.VerifyAllMocks();
+
}
protected virtual void WithStrictMocker()
diff --git a/NzbDrone.Web/Controllers/UpdateController.cs b/NzbDrone.Web/Controllers/UpdateController.cs
index bb0b39722..bb9d173d4 100644
--- a/NzbDrone.Web/Controllers/UpdateController.cs
+++ b/NzbDrone.Web/Controllers/UpdateController.cs
@@ -1,5 +1,8 @@
-using System.Linq;
+using System;
+using System.IO;
+using System.Linq;
using System.Web.Mvc;
+using NzbDrone.Common;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Web.Models;
@@ -10,23 +13,39 @@ public class UpdateController : Controller
{
private readonly UpdateProvider _updateProvider;
private readonly JobProvider _jobProvider;
+ private readonly EnviromentProvider _enviromentProvider;
+ private readonly DiskProvider _diskProvider;
- public UpdateController(UpdateProvider updateProvider, JobProvider jobProvider)
+ public UpdateController(UpdateProvider updateProvider, JobProvider jobProvider,
+ EnviromentProvider enviromentProvider, DiskProvider diskProvider)
{
_updateProvider = updateProvider;
_jobProvider = jobProvider;
+ _enviromentProvider = enviromentProvider;
+ _diskProvider = diskProvider;
}
public ActionResult Index()
{
- return View(_updateProvider.GetAvilableUpdate());
+ var updateModel = new UpdateModel();
+ updateModel.UpdatePackage = _updateProvider.GetAvilableUpdate();
+ updateModel.LogFiles = _updateProvider.UpdateLogFile();
+ updateModel.LogFolder = _enviromentProvider.GetUpdateLogFolder();
+
+ return View(updateModel);
}
public ActionResult StartUpdate()
{
_jobProvider.QueueJob(typeof(AppUpdateJob), 0, 0);
- return Json(new NotificationResult() { Title = "Update will begin shortly", NotificationType = NotificationType.Info, Text = "NzbDrone will restart automatically."});
+ return Json(new NotificationResult { Title = "Update will begin shortly", NotificationType = NotificationType.Info, Text = "NzbDrone will restart automatically." });
+ }
+
+ public ActionResult ViewLog( string filepath)
+ {
+ ViewBag.Log = _diskProvider.ReadAllText(filepath).Replace(Environment.NewLine, "
");
+ return View();
}
}
}
diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs
index 35509a499..0a05e82f1 100644
--- a/NzbDrone.Web/Global.asax.cs
+++ b/NzbDrone.Web/Global.asax.cs
@@ -40,12 +40,10 @@ public static void RegisterRoutes(RouteCollection routes)
protected override void OnApplicationStarted()
{
base.OnApplicationStarted();
- //WebAssetDefaultSettings.UseTelerikContentDeliveryNetwork = true;
RegisterRoutes(RouteTable.Routes);
- //base.OnApplicationStarted();
AreaRegistration.RegisterAllAreas();
- var razor = ViewEngines.Engines.Where(e => e.GetType() == typeof(RazorViewEngine)).Single();
+ var razor = ViewEngines.Engines.Single(e => e is RazorViewEngine);
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(razor);
@@ -57,12 +55,12 @@ protected override void OnApplicationStarted()
protected override IKernel CreateKernel()
{
LogManager.Configuration = new XmlLoggingConfiguration(new EnviromentProvider().GetNlogConfigPath(), false);
-
- Common.LogConfiguration.RegisterUdpLogger();
- Common.LogConfiguration.RegisterExceptioneer();
- Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
- Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
-
+
+ LogConfiguration.RegisterUdpLogger();
+ LogConfiguration.RegisterExceptioneer();
+ LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
+ LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
+
var dispatch = new CentralDispatch();
Logger.Info("NzbDrone Starting up.");
diff --git a/NzbDrone.Web/Models/UpdateModel.cs b/NzbDrone.Web/Models/UpdateModel.cs
new file mode 100644
index 000000000..cf2776d38
--- /dev/null
+++ b/NzbDrone.Web/Models/UpdateModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using NzbDrone.Core.Model;
+
+namespace NzbDrone.Web.Models
+{
+ public class UpdateModel
+ {
+ public UpdatePackage UpdatePackage { get; set; }
+ public Dictionary LogFiles { get; set; }
+ public String LogFolder { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj
index e44164400..94274ac7e 100644
--- a/NzbDrone.Web/NzbDrone.Web.csproj
+++ b/NzbDrone.Web/NzbDrone.Web.csproj
@@ -497,6 +497,7 @@
+
@@ -945,6 +946,9 @@
+
+
+