Fixed: Loading queue with pending releases for deleted movies

pull/10611/head
Bogdan 2 weeks ago
parent b42f7e09f9
commit 48a79eb7d3

@ -72,6 +72,15 @@ namespace NzbDrone.Core.Datastore
return builder.LeftJoin($"\"{rightTable}\" ON {wb.ToString()}");
}
public static SqlBuilder InnerJoin<TLeft, TRight>(this SqlBuilder builder, Expression<Func<TLeft, TRight, bool>> filter)
{
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
var rightTable = TableMapping.Mapper.TableNameMapping(typeof(TRight));
return builder.InnerJoin($"\"{rightTable}\" ON {wb}");
}
public static SqlBuilder GroupBy<TModel>(this SqlBuilder builder, Expression<Func<TModel, object>> property)
{
var table = TableMapping.Mapper.TableNameMapping(typeof(TModel));

@ -1,6 +1,7 @@
using System.Collections.Generic;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Download.Pending
{
@ -30,7 +31,11 @@ namespace NzbDrone.Core.Download.Pending
public List<PendingRelease> WithoutFallback()
{
return Query(x => x.Reason != PendingReleaseReason.Fallback);
var builder = new SqlBuilder(_database.DatabaseType)
.InnerJoin<PendingRelease, Movie>((p, m) => p.MovieId == m.Id)
.Where<PendingRelease>(p => p.Reason != PendingReleaseReason.Fallback);
return Query(builder);
}
}
}

@ -254,10 +254,7 @@ namespace NzbDrone.Core.Download.Pending
{
foreach (var movie in knownRemoteMovies.Values.Select(v => v.Movie))
{
if (!movieMap.ContainsKey(movie.Id))
{
movieMap[movie.Id] = movie;
}
movieMap.TryAdd(movie.Id, movie);
}
}
@ -273,7 +270,7 @@ namespace NzbDrone.Core.Download.Pending
// Just in case the movie was removed, but wasn't cleaned up yet (housekeeper will clean it up)
if (movie == null)
{
return null;
continue;
}
// Languages will be empty if added before upgrading to v4, reparsing the languages if they're empty will set it to Unknown or better.

Loading…
Cancel
Save