Fixing some issues with the crawler & most issues of the ressource editor

This commit is contained in:
Zoe Roux 2020-12-25 23:46:32 +01:00
parent c084208013
commit a6d3107329
3 changed files with 16 additions and 21 deletions

View File

@ -24,7 +24,7 @@ namespace Kyoo.Models
public bool IsMovie { get; set; } public bool IsMovie { get; set; }
public virtual IEnumerable<MetadataID> ExternalIDs { get; set; } [EditableRelation] public virtual IEnumerable<MetadataID> ExternalIDs { get; set; }
[JsonIgnore] public int? StudioID { get; set; } [JsonIgnore] public int? StudioID { get; set; }

View File

@ -159,17 +159,15 @@ namespace Kyoo.Controllers
if (old == null) if (old == null)
throw new ItemNotFound($"No resource found with the ID {edited.ID}."); throw new ItemNotFound($"No resource found with the ID {edited.ID}.");
IEnumerable<NavigationEntry> relations = Database.Entry(old).Collections
.Concat(Database.Entry(old).Navigations);
foreach (NavigationEntry navigation in relations)
if (navigation.Metadata.PropertyInfo.GetCustomAttribute<EditableRelation>() != null)
await navigation.LoadAsync();
foreach (NavigationEntry navigation in Database.Entry(old).Navigations)
if (navigation.Metadata.PropertyInfo.GetCustomAttribute<EditableRelation>() != null
&& navigation.Metadata.GetGetter().GetClrValue(edited) != default)
await navigation.LoadAsync();
if (resetOld) if (resetOld)
Utility.Nullify(old); Utility.Nullify(old);
Utility.Complete(old, edited); Utility.Complete(old, edited);
// TODO Validation set values & setting values trigger a change round in the OEM. A change round should only be triggered if the item is actually different.
await Validate(old); await Validate(old);
await Database.SaveChangesAsync(); await Database.SaveChangesAsync();
return old; return old;

View File

@ -8,7 +8,6 @@ using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Kyoo.Models.Exceptions; using Kyoo.Models.Exceptions;
using Kyoo.Models.Watch;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Controllers namespace Kyoo.Controllers
@ -121,18 +120,16 @@ namespace Kyoo.Controllers
.Where(x => IsVideo(x) && episodes.All(y => y.Path != x)) .Where(x => IsVideo(x) && episodes.All(y => y.Path != x))
.GroupBy(Path.GetDirectoryName) .GroupBy(Path.GetDirectoryName)
.ToList(); .ToList();
IEnumerable<Task> tasks = shows
.Select(x => x.First())
.Select(x => RegisterFile(x, x.Substring(path.Length), library, cancellationToken));
foreach (Task[] showTasks in tasks.BatchBy(_parallelTasks))
await Task.WhenAll(showTasks);
tasks = shows IEnumerable<string> tasks = shows.Select(x => x.First());
.SelectMany(x => x.Skip(1)) foreach (string[] showTasks in tasks.BatchBy(_parallelTasks))
.Select(x => RegisterFile(x, x.Substring(path.Length), library, cancellationToken)); await Task.WhenAll(showTasks
foreach (Task[] episodeTasks in tasks.BatchBy(_parallelTasks * 2)) .Select(x => RegisterFile(x, x.Substring(path.Length), library, cancellationToken)));
await Task.WhenAll(episodeTasks);
tasks = shows.SelectMany(x => x.Skip(1));
foreach (string[] episodeTasks in tasks.BatchBy(_parallelTasks * 2))
await Task.WhenAll(episodeTasks
.Select(x => RegisterFile(x, x.Substring(path.Length), library, cancellationToken)));
} }
} }
@ -233,7 +230,7 @@ namespace Kyoo.Controllers
try try
{ {
await libraryManager.RegisterShow(show); show = await libraryManager.RegisterShow(show);
} }
catch (DuplicatedItemException) catch (DuplicatedItemException)
{ {