Lots of Bugfixes (#2356)

This commit is contained in:
Joe Milazzo 2023-10-27 16:18:56 -05:00 committed by GitHub
parent 86e931dd9a
commit 226d6831df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 359 additions and 225 deletions

View file

@ -279,9 +279,23 @@ public class ParseScannedFiles
IEnumerable<string> folders, string libraryName, bool isLibraryScan,
IDictionary<string, IList<SeriesModified>> seriesPaths, Func<Tuple<bool, IList<ParserInfo>>, Task>? processSeriesInfos, bool forceCheck = false)
{
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress, MessageFactory.FileScanProgressEvent("File Scan Starting", libraryName, ProgressEventType.Started));
foreach (var folderPath in folders)
{
try
{
await ProcessFiles(folderPath, isLibraryScan, seriesPaths, ProcessFolder, forceCheck);
}
catch (ArgumentException ex)
{
_logger.LogError(ex, "[ScannerService] The directory '{FolderPath}' does not exist", folderPath);
}
}
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress, MessageFactory.FileScanProgressEvent("File Scan Done", libraryName, ProgressEventType.Ended));
return;
async Task ProcessFolder(IList<string> files, string folder)
{
var normalizedFolder = Parser.Parser.NormalizePath(folder);
@ -340,21 +354,6 @@ public class ParseScannedFiles
}
}
}
foreach (var folderPath in folders)
{
try
{
await ProcessFiles(folderPath, isLibraryScan, seriesPaths, ProcessFolder, forceCheck);
}
catch (ArgumentException ex)
{
_logger.LogError(ex, "[ScannerService] The directory '{FolderPath}' does not exist", folderPath);
}
}
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress, MessageFactory.FileScanProgressEvent("File Scan Done", libraryName, ProgressEventType.Ended));
}
/// <summary>

View file

@ -38,7 +38,7 @@ public class DefaultParser : IDefaultParser
ParserInfo ret;
if (Parser.IsEpub(filePath))
if (Parser.IsEpub(filePath)) // NOTE: Will this ever be called? Because we use ReadingService to handle parse
{
ret = new ParserInfo
{

View file

@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using API.Entities.Enums;
using API.Extensions;
namespace API.Services.Tasks.Scanner.Parser;
@ -927,7 +928,7 @@ public static class Parser
}
var tokens = range.Replace("_", string.Empty).Split("-");
return tokens.Min(float.Parse);
return tokens.Min(t => t.AsFloat());
}
catch
{
@ -945,7 +946,7 @@ public static class Parser
}
var tokens = range.Replace("_", string.Empty).Split("-");
return tokens.Max(float.Parse);
return tokens.Max(t => t.AsFloat());
}
catch
{

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using API.Data;
@ -21,6 +22,8 @@ using Microsoft.Extensions.Logging;
namespace API.Services.Tasks.Scanner;
#nullable enable
public interface IProcessSeries
{
/// <summary>
@ -208,7 +211,7 @@ public class ProcessSeries : IProcessSeries
.ToList()}));
await _eventHub.SendMessageAsync(MessageFactory.Error,
MessageFactory.ErrorEvent($"There was an issue writing to the DB for Series {series}",
MessageFactory.ErrorEvent($"There was an issue writing to the DB for Series {series.OriginalName}",
ex.Message));
return;
}
@ -614,7 +617,7 @@ public class ProcessSeries : IProcessSeries
// Add files
var specialTreatment = info.IsSpecialInfo();
AddOrUpdateFileForChapter(chapter, info, forceUpdate);
chapter.Number = Parser.Parser.MinNumberFromRange(info.Chapters) + string.Empty;
chapter.Number = Parser.Parser.MinNumberFromRange(info.Chapters).ToString(CultureInfo.InvariantCulture);
chapter.Range = specialTreatment ? info.Filename : info.Chapters;
}
@ -886,7 +889,7 @@ public class ProcessSeries : IProcessSeries
}
}
action(genre, newTag);
action(genre!, newTag);
}
}