mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Cleaning up
This commit is contained in:
parent
7694bd97ae
commit
51fa75214b
@ -51,8 +51,8 @@ namespace Kyoo
|
|||||||
services.AddDbContext<DatabaseContext>(options =>
|
services.AddDbContext<DatabaseContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseLazyLoadingProxies()
|
options.UseLazyLoadingProxies()
|
||||||
.UseNpgsql(_configuration.GetConnectionString("Database"));
|
.UseNpgsql(_configuration.GetConnectionString("Database"))
|
||||||
// .EnableSensitiveDataLogging()
|
.EnableSensitiveDataLogging();
|
||||||
// .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
|
// .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ namespace Kyoo.Controllers
|
|||||||
foreach (Library library in libraries)
|
foreach (Library library in libraries)
|
||||||
library.Providers = library.Providers;
|
library.Providers = library.Providers;
|
||||||
|
|
||||||
await Task.WhenAll(libraries.Select(x => Scan(x, episodes, cancellationToken)));
|
await Task.WhenAll(libraries.Select(x => Scan(x, episodes, cancellationToken)).ToArray());
|
||||||
|
Console.WriteLine("Done.");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -79,7 +80,7 @@ namespace Kyoo.Controllers
|
|||||||
private Task Scan(Library library, IEnumerable<Episode> episodes, CancellationToken cancellationToken)
|
private Task Scan(Library library, IEnumerable<Episode> episodes, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Scanning library {library.Name} at {string.Join(", ", library.Paths)}.");
|
Console.WriteLine($"Scanning library {library.Name} at {string.Join(", ", library.Paths)}.");
|
||||||
return Task.WhenAll(library.Paths.Select(async path =>
|
return Task.WhenAll(library.Paths.Select(path =>
|
||||||
{
|
{
|
||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -91,36 +92,33 @@ namespace Kyoo.Controllers
|
|||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException)
|
catch (DirectoryNotFoundException)
|
||||||
{
|
{
|
||||||
await Console.Error.WriteLineAsync($"The library's directory {path} could not be found (library slug: {library.Slug})");
|
Console.Error.WriteLine($"The library's directory {path} could not be found (library slug: {library.Slug})");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
catch (PathTooLongException)
|
catch (PathTooLongException)
|
||||||
{
|
{
|
||||||
await Console.Error.WriteLineAsync($"The library's directory {path} is too long for this system. (library slug: {library.Slug})");
|
Console.Error.WriteLine($"The library's directory {path} is too long for this system. (library slug: {library.Slug})");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
await Console.Error.WriteLineAsync($"The library's directory {path} is invalid. (library slug: {library.Slug})");
|
Console.Error.WriteLine($"The library's directory {path} is invalid. (library slug: {library.Slug})");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException)
|
catch (UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
await Console.Error.WriteLineAsync($"Permission denied: can't access library's directory at {path}. (library slug: {library.Slug})");
|
Console.Error.WriteLine($"Permission denied: can't access library's directory at {path}. (library slug: {library.Slug})");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.WhenAll(files.Select(file =>
|
return Task.WhenAll(files.Select(file =>
|
||||||
//foreach (string file in files)
|
|
||||||
{
|
{
|
||||||
if (!IsVideo(file) || episodes.Any(x => x.Path == file))
|
if (!IsVideo(file) || episodes.Any(x => x.Path == file))
|
||||||
/*continue;*/ return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
string relativePath = file.Substring(path.Length);
|
string relativePath = file.Substring(path.Length);
|
||||||
return /*await*/ RegisterFile(file, relativePath, library, cancellationToken);
|
return RegisterFile(file, relativePath, library, cancellationToken);
|
||||||
}));
|
}).ToArray());
|
||||||
|
}).ToArray());
|
||||||
// return Task.CompletedTask;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RegisterFile(string path, string relativePath, Library library, CancellationToken token)
|
private async Task RegisterFile(string path, string relativePath, Library library, CancellationToken token)
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning",
|
"Default": "Warning",
|
||||||
"Microsoft": "Warning",
|
"Microsoft": "Warning",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information",
|
||||||
|
"Microsoft.EntityFrameworkCore.DbUpdateException": "None"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user