Fixed an off by 1 issue with reading manga.
This commit is contained in:
parent
a6b49052b9
commit
9a50241734
2 changed files with 17 additions and 1 deletions
|
@ -106,12 +106,18 @@ namespace API.Services
|
|||
var chapterFiles = chapter.Files ?? await _unitOfWork.VolumeRepository.GetFilesForChapter(chapter.Id);
|
||||
foreach (var mangaFile in chapterFiles)
|
||||
{
|
||||
if (page < (mangaFile.NumberOfPages + pagesSoFar))
|
||||
if (page <= (mangaFile.NumberOfPages + pagesSoFar))
|
||||
{
|
||||
var path = GetCachePath(chapter.Id);
|
||||
var files = _directoryService.GetFiles(path, Parser.Parser.ImageFileExtensions);
|
||||
Array.Sort(files, _numericComparer);
|
||||
|
||||
// Since array is 0 based, we need to keep that in account (only affects last image)
|
||||
if (page - 1 == files.Length)
|
||||
{
|
||||
return (files.ElementAt(page - 1 - pagesSoFar), mangaFile);
|
||||
}
|
||||
|
||||
return (files.ElementAt(page - pagesSoFar), mangaFile);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue