mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Handling directory errors on library scan
This commit is contained in:
parent
7530d239d9
commit
602661db40
@ -79,14 +79,38 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
|
string[] files;
|
||||||
await Task.WhenAll(Directory.GetFiles(path, "*", SearchOption.AllDirectories).Select(file =>
|
try
|
||||||
|
{
|
||||||
|
files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
|
||||||
|
}
|
||||||
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"The library's directory {path} could not be found (library slug: {library.Slug})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
catch (PathTooLongException)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"The library's directory {path} is too long for this system. (library slug: {library.Slug})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"The library's directory {path} is invalid. (library slug: {library.Slug})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Permission denied: can't access library's directory at {path}. (library slug: {library.Slug})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
await Task.WhenAll(files.Select(file =>
|
||||||
{
|
{
|
||||||
if (!IsVideo(file) || _libraryManager.GetEpisodes().Any(x => x.Path == file))
|
if (!IsVideo(file) || _libraryManager.GetEpisodes().Any(x => x.Path == file))
|
||||||
return null;
|
return null;
|
||||||
string relativePath = file.Substring(path.Length);
|
string relativePath = file.Substring(path.Length);
|
||||||
return RegisterFile(file, relativePath, library, cancellationToken);
|
return RegisterFile(file, relativePath, library, cancellationToken);
|
||||||
}));
|
}).Where(x => x != null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user