mirror of
https://github.com/Radarr/Radarr
synced 2025-01-30 19:31:35 +00:00
Fixed logging for Settings Controller and QualityProvider
Setup/Update of Default QualityProfiles will occur on start
This commit is contained in:
parent
519e2df560
commit
48e5b36936
4 changed files with 165 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
|
@ -9,6 +10,7 @@
|
|||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Fakes;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using SubSonic.DataProviders;
|
||||
using SubSonic.Query;
|
||||
using SubSonic.Repository;
|
||||
|
@ -76,6 +78,7 @@ public static void BindKernel()
|
|||
|
||||
ForceMigration(_kernel.Get<IRepository>());
|
||||
SetupIndexers(_kernel.Get<IRepository>()); //Setup the default set of indexers on start-up
|
||||
SetupDefaultQualityProfiles(_kernel.Get<IRepository>()); //Setup the default QualityProfiles on start-up
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,5 +234,134 @@ private static void SetupIndexers(IRepository repository)
|
|||
repository.Update(nzbsrusIndexer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetupDefaultQualityProfiles(IRepository repository)
|
||||
{
|
||||
var sdtv = new QualityProfile
|
||||
{
|
||||
Name = "SDTV",
|
||||
Allowed = new List<QualityTypes> {QualityTypes.TV},
|
||||
Cutoff = QualityTypes.TV
|
||||
};
|
||||
|
||||
var dvd = new QualityProfile
|
||||
{
|
||||
Name = "DVD SD",
|
||||
Allowed = new List<QualityTypes> {QualityTypes.DVD},
|
||||
Cutoff = QualityTypes.DVD
|
||||
};
|
||||
|
||||
var bdrip = new QualityProfile
|
||||
{
|
||||
Name = "BDRip",
|
||||
Allowed = new List<QualityTypes> {QualityTypes.BDRip},
|
||||
Cutoff = QualityTypes.BDRip
|
||||
};
|
||||
|
||||
var hdtv = new QualityProfile
|
||||
{
|
||||
Name = "HDTV",
|
||||
Allowed = new List<QualityTypes> {QualityTypes.HDTV},
|
||||
Cutoff = QualityTypes.HDTV
|
||||
};
|
||||
|
||||
var webdl = new QualityProfile
|
||||
{
|
||||
Name = "WEBDL",
|
||||
Allowed = new List<QualityTypes> {QualityTypes.WEBDL},
|
||||
Cutoff = QualityTypes.WEBDL
|
||||
};
|
||||
|
||||
var bluray = new QualityProfile
|
||||
{
|
||||
Name = "Bluray",
|
||||
Allowed = new List<QualityTypes> {QualityTypes.Bluray},
|
||||
Cutoff = QualityTypes.Bluray
|
||||
};
|
||||
|
||||
//Add or Update SDTV
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sdtv.Name));
|
||||
if (!repository.Exists<QualityProfile>(i => i.Name == sdtv.Name))
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sdtv.Name));
|
||||
repository.Add(sdtv);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", sdtv.Name));
|
||||
repository.Update(sdtv);
|
||||
}
|
||||
|
||||
//Add or Update DVD
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", dvd.Name));
|
||||
if (!repository.Exists<QualityProfile>(i => i.Name == dvd.Name))
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", dvd.Name));
|
||||
repository.Add(dvd);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", dvd.Name));
|
||||
repository.Update(dvd);
|
||||
}
|
||||
|
||||
//Add or Update BDRip
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", bdrip.Name));
|
||||
if (!repository.Exists<QualityProfile>(i => i.Name == bdrip.Name))
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", bdrip.Name));
|
||||
repository.Add(bdrip);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", bdrip.Name));
|
||||
repository.Update(bdrip);
|
||||
}
|
||||
|
||||
//Add or Update HDTV
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hdtv.Name));
|
||||
if (!repository.Exists<QualityProfile>(i => i.Name == hdtv.Name))
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hdtv.Name));
|
||||
repository.Add(hdtv);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", hdtv.Name));
|
||||
repository.Update(hdtv);
|
||||
}
|
||||
|
||||
//Add or Update WEBDL
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", webdl.Name));
|
||||
if (!repository.Exists<QualityProfile>(i => i.Name == webdl.Name))
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", webdl.Name));
|
||||
repository.Add(webdl);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", webdl.Name));
|
||||
repository.Update(webdl);
|
||||
}
|
||||
|
||||
//Add or Update Bluray
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", bluray.Name));
|
||||
if (!repository.Exists<QualityProfile>(i => i.Name == bluray.Name))
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", bluray.Name));
|
||||
repository.Add(bluray);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", bluray.Name));
|
||||
repository.Update(bluray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using SubSonic.Repository;
|
||||
|
||||
|
@ -10,6 +11,7 @@ namespace NzbDrone.Core.Providers
|
|||
public class QualityProvider : IQualityProvider
|
||||
{
|
||||
private IRepository _sonicRepo;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public QualityProvider(IRepository sonicRepo)
|
||||
{
|
||||
|
@ -27,8 +29,8 @@ public void Update(QualityProfile profile)
|
|||
{
|
||||
if (!_sonicRepo.Exists<QualityProfile>(q => q.ProfileId == profile.ProfileId))
|
||||
{
|
||||
//Log Error
|
||||
throw new InvalidOperationException("Unable to update none existing profile");
|
||||
Logger.Error("Unable to update non-existing profile");
|
||||
throw new InvalidOperationException("Unable to update non-existing profile");
|
||||
}
|
||||
|
||||
_sonicRepo.Update(profile);
|
||||
|
|
|
@ -123,11 +123,12 @@ public ActionResult Index(SettingsModel data)
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (Request.IsAjaxRequest())
|
||||
return Content("Settings Saved.");
|
||||
Logger.Error("Error saving settings.");
|
||||
|
||||
return Content("Settings Saved.");
|
||||
Logger.Error("");
|
||||
if (Request.IsAjaxRequest())
|
||||
return Content("Error saving settings.");
|
||||
|
||||
return Content("Error saving settings.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -258,6 +259,29 @@ public ActionResult SaveDownloads(SettingsModel data)
|
|||
return Content("Settings Saved.");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult SaveQuality(QualityModel data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorException(e.Message, e);
|
||||
if (Request.IsAjaxRequest())
|
||||
return Content("Error Saving Settings, please fix any errors");
|
||||
|
||||
return Content("Error Saving Settings, please fix any errors");
|
||||
}
|
||||
|
||||
if (Request.IsAjaxRequest())
|
||||
return Content("Settings Saved.");
|
||||
|
||||
return Content("Settings Saved.");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult SortedList(List<object > items)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
.ui-state-highlight { height: 1.5em; line-height: 1.2em; }
|
||||
</style>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#sortable").sortable({
|
||||
|
@ -59,7 +58,7 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<% using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
|
||||
<% using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
|
||||
{%>
|
||||
<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>
|
||||
|
||||
|
|
Loading…
Reference in a new issue