Adding a try catch in the crawler

This commit is contained in:
Zoe Roux 2020-01-26 22:12:38 +01:00
parent 57c5cefaf8
commit 42bf34064a
3 changed files with 13 additions and 6 deletions

View File

@ -36,7 +36,14 @@ namespace Kyoo.Controllers
if (isRunning)
return;
isRunning = true;
StartAsync(cancellation.Token);
try
{
StartAsync(cancellation.Token);
}
catch (Exception ex)
{
Console.Error.WriteLine($"Unknown exception thrown durring libraries scan.\nException: {ex.Message}");
}
}
public void Cancel()
@ -52,7 +59,6 @@ namespace Kyoo.Controllers
IEnumerable<Episode> episodes = libraryManager.GetAllEpisodes();
IEnumerable<Library> libraries = libraryManager.GetLibraries();
Debug.WriteLine("&Crawler started");
foreach (Episode episode in episodes)
{
if (!File.Exists(episode.Path))
@ -63,7 +69,7 @@ namespace Kyoo.Controllers
await Scan(library, cancellationToken);
isRunning = false;
Debug.WriteLine("&Crawler stopped");
Console.WriteLine("Scan finished!");
}
private async Task Scan(Library library, CancellationToken cancellationToken)

View File

@ -56,10 +56,10 @@ namespace Kyoo.Controllers.TranscoderLink
}
}
else
tracks = null;
tracks = new Track[0];
free(ptr);
Console.WriteLine("&" + tracks?.Length + " tracks got at: " + path);
Console.WriteLine(tracks.Length + " tracks got at: " + path);
}
public static void ExtractSubtitles(string path, string outPath, out Track[] tracks)

View File

@ -1,9 +1,9 @@
using System;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Kyoo
{
@ -13,6 +13,7 @@ namespace Kyoo
{
IWebHost host = CreateWebHostBuilder(args).Build();
Console.WriteLine($"Running as: {Environment.UserName}");
using (IServiceScope serviceScope = host.Services.CreateScope())
{
IPluginManager pluginManager = serviceScope.ServiceProvider.GetService<IPluginManager>();