2011-11-22 07:55:09 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2011-11-14 07:01:51 +01:00
|
|
|
|
using System.Web.Mvc;
|
2011-11-22 07:55:09 +01:00
|
|
|
|
using NzbDrone.Common;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Jobs;
|
2011-11-14 07:01:51 +01:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Web.Models;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class UpdateController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly UpdateProvider _updateProvider;
|
|
|
|
|
private readonly JobProvider _jobProvider;
|
2011-11-22 07:55:09 +01:00
|
|
|
|
private readonly EnviromentProvider _enviromentProvider;
|
|
|
|
|
private readonly DiskProvider _diskProvider;
|
2011-11-14 07:01:51 +01:00
|
|
|
|
|
2011-11-22 07:55:09 +01:00
|
|
|
|
public UpdateController(UpdateProvider updateProvider, JobProvider jobProvider,
|
|
|
|
|
EnviromentProvider enviromentProvider, DiskProvider diskProvider)
|
2011-11-14 07:01:51 +01:00
|
|
|
|
{
|
|
|
|
|
_updateProvider = updateProvider;
|
|
|
|
|
_jobProvider = jobProvider;
|
2011-11-22 07:55:09 +01:00
|
|
|
|
_enviromentProvider = enviromentProvider;
|
|
|
|
|
_diskProvider = diskProvider;
|
2011-11-14 07:01:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
2011-11-22 07:55:09 +01:00
|
|
|
|
var updateModel = new UpdateModel();
|
2012-02-05 07:34:36 +01:00
|
|
|
|
updateModel.UpdatePackage = _updateProvider.GetAvilableUpdate(_enviromentProvider.Version);
|
2011-11-22 07:55:09 +01:00
|
|
|
|
updateModel.LogFiles = _updateProvider.UpdateLogFile();
|
|
|
|
|
updateModel.LogFolder = _enviromentProvider.GetUpdateLogFolder();
|
|
|
|
|
|
|
|
|
|
return View(updateModel);
|
2011-11-14 07:01:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult StartUpdate()
|
|
|
|
|
{
|
|
|
|
|
_jobProvider.QueueJob(typeof(AppUpdateJob), 0, 0);
|
|
|
|
|
|
2012-01-19 06:01:47 +01:00
|
|
|
|
return JsonNotificationResult.Info("Update will begin shortly", "NzbDrone will restart automatically.");
|
2011-11-22 07:55:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult ViewLog( string filepath)
|
|
|
|
|
{
|
|
|
|
|
ViewBag.Log = _diskProvider.ReadAllText(filepath).Replace(Environment.NewLine, "<br/>");
|
|
|
|
|
return View();
|
2011-11-14 07:01:51 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|