Merge pull request #772 from tidusjar/dev

Fixed #769
This commit is contained in:
Jamie 2016-12-13 09:50:45 +00:00 committed by GitHub
commit f7eec8bead
2 changed files with 25 additions and 10 deletions

View file

@ -4,6 +4,7 @@ using System.Data.Common;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Ninject; using Ninject;
using NLog;
using PlexRequests.Store; using PlexRequests.Store;
namespace PlexRequests.Core.Migration namespace PlexRequests.Core.Migration
@ -18,6 +19,7 @@ namespace PlexRequests.Core.Migration
private IKernel Kernel { get; } private IKernel Kernel { get; }
private ISqliteConfiguration Db { get; } private ISqliteConfiguration Db { get; }
private static Logger _log = LogManager.GetCurrentClassLogger();
public void MigrateToLatest() public void MigrateToLatest()
{ {
@ -25,13 +27,15 @@ namespace PlexRequests.Core.Migration
var versions = GetMigrations(); var versions = GetMigrations();
var dbVersion = con.GetVersionInfo().OrderByDescending(x => x.Version).FirstOrDefault() ?? var dbVersion = con.GetVersionInfo().OrderByDescending(x => x.Version).FirstOrDefault() ??
new TableCreation.VersionInfo { Version = 0 }; new TableCreation.VersionInfo {Version = 0};
foreach (var v in versions) foreach (var v in versions)
{ {
#if !DEBUG #if !DEBUG
if (v.Value.Version > dbVersion.Version) if (v.Value.Version > dbVersion.Version)
{ {
#endif #endif
try
{
// Assuming only one constructor // Assuming only one constructor
var ctor = v.Key.GetConstructors().FirstOrDefault(); var ctor = v.Key.GetConstructors().FirstOrDefault();
var dependencies = ctor.GetParameters().Select(param => Kernel.Get(param.ParameterType)).ToList(); var dependencies = ctor.GetParameters().Select(param => Kernel.Get(param.ParameterType)).ToList();
@ -44,6 +48,13 @@ namespace PlexRequests.Core.Migration
method.Invoke(classInstance, parametersArray); method.Invoke(classInstance, parametersArray);
} }
}
catch (Exception e)
{
_log.Fatal("Error when migrating");
_log.Fatal(e);
}
#if !DEBUG #if !DEBUG
} }
#endif #endif

View file

@ -246,6 +246,10 @@ namespace PlexRequests.Core.Migration.Migrations
var requestedModels = allRequests.ToList(); var requestedModels = allRequests.ToList();
foreach (var req in requestedModels) foreach (var req in requestedModels)
{ {
if (string.IsNullOrEmpty(req.PosterPath))
{
continue;
}
if (req.PosterPath.Contains("https://image.tmdb.org/t/p/w150/")) if (req.PosterPath.Contains("https://image.tmdb.org/t/p/w150/"))
{ {
var newImg = req.PosterPath.Replace("https://image.tmdb.org/t/p/w150/", string.Empty); var newImg = req.PosterPath.Replace("https://image.tmdb.org/t/p/w150/", string.Empty);