Bugfixes (#221)
* More regex! Bonus is now a keyword for specials * Regex enhancement, Sort chapters on next/prev chapter to ensure they always in proper order, and don't set JWT on starup when in development mode.
This commit is contained in:
parent
2f793af34c
commit
308e2b48a0
4 changed files with 11 additions and 7 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Comparators;
|
||||
using API.DTOs;
|
||||
using API.Entities;
|
||||
using API.Extensions;
|
||||
|
|
@ -19,6 +20,7 @@ namespace API.Controllers
|
|||
private readonly ICacheService _cacheService;
|
||||
private readonly ILogger<ReaderController> _logger;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ChapterSortComparer _chapterSortComparer = new ChapterSortComparer();
|
||||
|
||||
public ReaderController(IDirectoryService directoryService, ICacheService cacheService,
|
||||
ILogger<ReaderController> logger, IUnitOfWork unitOfWork)
|
||||
|
|
@ -252,9 +254,9 @@ namespace API.Controllers
|
|||
public async Task<ActionResult<int>> GetNextChapter(int seriesId, int volumeId, int currentChapterId)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
||||
//if (user == null) return // TODO: Need to have GetUSerByUsernameAsync checks to throw not authorized (401) if it is null all throughout code
|
||||
var volumes = await _unitOfWork.SeriesRepository.GetVolumesDtoAsync(seriesId, user.Id);
|
||||
var currentVolume = await _unitOfWork.SeriesRepository.GetVolumeAsync(volumeId);
|
||||
|
||||
|
||||
if (currentVolume.Number == 0)
|
||||
{
|
||||
|
|
@ -268,7 +270,7 @@ namespace API.Controllers
|
|||
if (currentChapterId == chapter.Id) next = true;
|
||||
}
|
||||
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters, currentChapterId);
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer), currentChapterId);
|
||||
if (chapterId > 0) return Ok(chapterId);
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +278,7 @@ namespace API.Controllers
|
|||
{
|
||||
if (volume.Number == currentVolume.Number && volume.Chapters.Count > 1)
|
||||
{
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters, currentChapterId);
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer), currentChapterId);
|
||||
if (chapterId > 0) return Ok(chapterId);
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +322,7 @@ namespace API.Controllers
|
|||
|
||||
if (currentVolume.Number == 0)
|
||||
{
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters.Reverse(), currentChapterId);
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer).Reverse(), currentChapterId);
|
||||
if (chapterId > 0) return Ok(chapterId);
|
||||
}
|
||||
|
||||
|
|
@ -328,7 +330,7 @@ namespace API.Controllers
|
|||
{
|
||||
if (volume.Number == currentVolume.Number)
|
||||
{
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters.Reverse(), currentChapterId);
|
||||
var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer).Reverse(), currentChapterId);
|
||||
if (chapterId > 0) return Ok(chapterId);
|
||||
}
|
||||
if (volume.Number == currentVolume.Number - 1)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace API.Parser
|
|||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
//Tonikaku Cawaii [Volume 11], Darling in the FranXX - Volume 01.cbz
|
||||
new Regex(
|
||||
@"(?<Series>.*)(?: _|-|\[|\() ?v",
|
||||
@"(?<Series>.*)(?: _|-|\[|\()\s?vol(ume)?",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
// Momo The Blood Taker - Chapter 027 Violent Emotion.cbz
|
||||
new Regex(
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace API
|
|||
public static async Task Main(string[] args)
|
||||
{
|
||||
// Before anything, check if JWT has been generated properly or if user still has default
|
||||
if (!Configuration.CheckIfJwtTokenSet(GetAppSettingFilename()))
|
||||
if (!Configuration.CheckIfJwtTokenSet(GetAppSettingFilename()) && Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") != Environments.Development)
|
||||
{
|
||||
Console.WriteLine("Generating JWT TokenKey for encrypting user sessions...");
|
||||
var rBytes = new byte[24];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue