Another round of bugfixes (#3707)

This commit is contained in:
Joe Milazzo 2025-04-06 13:14:04 -05:00 committed by GitHub
parent cbb97208b8
commit 93dc6534fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 412 additions and 335 deletions

View file

@ -151,7 +151,8 @@ public class SettingsController : BaseApiController
try
{
return Ok(await _settingsService.UpdateSettings(updateSettingsDto));
var d = await _settingsService.UpdateSettings(updateSettingsDto);
return Ok(d);
}
catch (KavitaException ex)
{

View file

@ -49,6 +49,7 @@ public interface IReadingListRepository
Task<IList<string>> GetRandomCoverImagesAsync(int readingListId);
Task<IList<string>> GetAllCoverImagesAsync();
Task<bool> ReadingListExists(string name);
Task<bool> ReadingListExistsForUser(string name, int userId);
IEnumerable<PersonDto> GetReadingListPeopleAsync(int readingListId, PersonRole role);
Task<ReadingListCast> GetReadingListAllPeopleAsync(int readingListId);
Task<IList<ReadingList>> GetAllWithCoversInDifferentEncoding(EncodeFormat encodeFormat);
@ -109,6 +110,7 @@ public class ReadingListRepository : IReadingListRepository
.SelectMany(r => r.Items.Select(ri => ri.Chapter.CoverImage))
.Where(t => !string.IsNullOrEmpty(t))
.ToListAsync();
return data
.OrderBy(_ => random.Next())
.Take(4)
@ -123,6 +125,13 @@ public class ReadingListRepository : IReadingListRepository
.AnyAsync(x => x.NormalizedTitle != null && x.NormalizedTitle.Equals(normalized));
}
public async Task<bool> ReadingListExistsForUser(string name, int userId)
{
var normalized = name.ToNormalized();
return await _context.ReadingList
.AnyAsync(x => x.NormalizedTitle != null && x.NormalizedTitle.Equals(normalized) && x.AppUserId == userId);
}
public IEnumerable<PersonDto> GetReadingListPeopleAsync(int readingListId, PersonRole role)
{
return _context.ReadingListItem

View file

@ -25,7 +25,7 @@ public class ChapterBuilder : IEntityBuilder<Chapter>
MinNumber = Parser.MinNumberFromRange(number),
MaxNumber = Parser.MaxNumberFromRange(number),
SortOrder = Parser.MinNumberFromRange(number),
Files = new List<MangaFile>(),
Files = [],
Pages = 1,
CreatedUtc = DateTime.UtcNow
};

View file

@ -473,6 +473,7 @@ public class ReadingListService : IReadingListService
_logger.LogInformation("Processing Reading Lists for {SeriesName}", series.Name);
var user = await _unitOfWork.UserRepository.GetDefaultAdminUser();
series.Metadata ??= new SeriesMetadataBuilder().Build();
foreach (var chapter in series.Volumes.SelectMany(v => v.Chapters))
{
var pairs = new List<Tuple<string, string>>();
@ -578,14 +579,14 @@ public class ReadingListService : IReadingListService
{
CblName = cblReading.Name,
Success = CblImportResult.Success,
Results = new List<CblBookResult>(),
Results = [],
SuccessfulInserts = new List<CblBookResult>()
};
if (IsCblEmpty(cblReading, importSummary, out var readingListFromCbl)) return readingListFromCbl;
// Is there another reading list with the same name?
if (await _unitOfWork.ReadingListRepository.ReadingListExists(cblReading.Name))
// Is there another reading list with the same name on the user's account?
if (await _unitOfWork.ReadingListRepository.ReadingListExistsForUser(cblReading.Name, userId))
{
importSummary.Success = CblImportResult.Fail;
importSummary.Results.Add(new CblBookResult
@ -600,9 +601,6 @@ public class ReadingListService : IReadingListService
var userSeries =
(await _unitOfWork.SeriesRepository.GetAllSeriesByNameAsync(uniqueSeries, userId, SeriesIncludes.Chapters)).ToList();
// How can we match properly with ComicVine library when year is part of the series unless we do this in 2 passes and see which has a better match
if (userSeries.Count == 0)
{
// Report that no series exist in the reading list

View file

@ -21,8 +21,8 @@ namespace API.Services;
public interface ISettingsService
{
Task<ActionResult<MetadataSettingsDto>> UpdateMetadataSettings(MetadataSettingsDto dto);
Task<ActionResult<ServerSettingDto>> UpdateSettings(ServerSettingDto updateSettingsDto);
Task<MetadataSettingsDto> UpdateMetadataSettings(MetadataSettingsDto dto);
Task<ServerSettingDto> UpdateSettings(ServerSettingDto updateSettingsDto);
}
@ -50,7 +50,7 @@ public class SettingsService : ISettingsService
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<ActionResult<MetadataSettingsDto>> UpdateMetadataSettings(MetadataSettingsDto dto)
public async Task<MetadataSettingsDto> UpdateMetadataSettings(MetadataSettingsDto dto)
{
var existingMetadataSetting = await _unitOfWork.SettingsRepository.GetMetadataSettings();
existingMetadataSetting.Enabled = dto.Enabled;
@ -108,7 +108,7 @@ public class SettingsService : ISettingsService
/// <param name="updateSettingsDto"></param>
/// <returns></returns>
/// <exception cref="KavitaException"></exception>
public async Task<ActionResult<ServerSettingDto>> UpdateSettings(ServerSettingDto updateSettingsDto)
public async Task<ServerSettingDto> UpdateSettings(ServerSettingDto updateSettingsDto)
{
// We do not allow CacheDirectory changes, so we will ignore.
var currentSettings = await _unitOfWork.SettingsRepository.GetSettingsAsync();

View file

@ -871,7 +871,10 @@ public class ParseScannedFiles
var prevIssue = string.Empty;
foreach (var chapter in chapters)
{
if (float.TryParse(chapter.Chapters, NumberStyles.Any, CultureInfo.InvariantCulture, out var parsedChapter))
// Use MinNumber in case there is a range, as otherwise sort order will cause it to be processed last
var chapterNum =
$"{Parser.Parser.MinNumberFromRange(chapter.Chapters).ToString(CultureInfo.InvariantCulture)}";
if (float.TryParse(chapterNum, NumberStyles.Any, CultureInfo.InvariantCulture, out var parsedChapter))
{
// Parsed successfully, use the numeric value
counter = parsedChapter;

View file

@ -24,7 +24,7 @@ public static partial class Parser
public static readonly TimeSpan RegexTimeout = TimeSpan.FromMilliseconds(500);
public const string ImageFileExtensions = @"^(\.png|\.jpeg|\.jpg|\.webp|\.gif|\.avif)"; // Don't forget to update CoverChooser
public const string ImageFileExtensions = @"(\.png|\.jpeg|\.jpg|\.webp|\.gif|\.avif)"; // Don't forget to update CoverChooser
public const string ArchiveFileExtensions = @"\.cbz|\.zip|\.rar|\.cbr|\.tar.gz|\.7zip|\.7z|\.cb7|\.cbt";
public const string EpubFileExtension = @"\.epub";
public const string PdfFileExtension = @"\.pdf";