Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
Joe Milazzo 2024-04-14 06:58:22 -05:00 committed by GitHub
parent 5a7fd25548
commit 8f4e1fbb36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 92 additions and 1287 deletions

View file

@ -596,14 +596,12 @@ public class DirectoryService : IDirectoryService
/// <returns></returns>
public string? FindLowestDirectoriesFromFiles(IEnumerable<string> libraryFolders, IList<string> filePaths)
{
var stopLookingForDirectories = false;
var dirs = new Dictionary<string, string>();
foreach (var folder in libraryFolders.Select(Tasks.Scanner.Parser.Parser.NormalizePath))
var normalizedFilePaths = filePaths.Select(Parser.NormalizePath).ToList();
foreach (var folder in libraryFolders.Select(Parser.NormalizePath))
{
if (stopLookingForDirectories) break;
foreach (var file in filePaths.Select(Tasks.Scanner.Parser.Parser.NormalizePath))
foreach (var file in normalizedFilePaths)
{
if (!file.Contains(folder)) continue;
@ -619,8 +617,16 @@ public class DirectoryService : IDirectoryService
if (dirs.Keys.Count == 1) return dirs.Keys.First();
if (dirs.Keys.Count > 1)
{
return dirs.Keys.Last();
// For each key, validate that each file exists in the key path
foreach (var folder in dirs.Keys)
{
if (normalizedFilePaths.TrueForAll(filePath => filePath.Contains(Parser.NormalizePath(folder))))
{
return folder;
}
}
}
return null;
}

View file

@ -265,7 +265,7 @@ public class TaskScheduler : ITaskScheduler
public void ScheduleUpdaterTasks()
{
_logger.LogInformation("Scheduling Auto-Update tasks");
RecurringJob.AddOrUpdate(CheckForUpdateId, () => CheckForUpdate(), $"0 */{Rnd.Next(1, 2)} * * *", RecurringJobOptions);
RecurringJob.AddOrUpdate(CheckForUpdateId, () => CheckForUpdate(), $"0 */{Rnd.Next(4, 6)} * * *", RecurringJobOptions);
BackgroundJob.Enqueue(() => CheckForUpdate());
}

View file

@ -463,7 +463,7 @@ public class ParseScannedFiles
chapter.IssueOrder = counter;
counter++;
}
return;
continue;
}
@ -479,7 +479,7 @@ public class ParseScannedFiles
chapter.IssueOrder = counter;
counter++;
}
return;
continue;
}
chapters = infos