Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: [OPDS] Recreate a pdf chapter's cache if images are missing (This happens when the pdf chapter is accessed first using the web reader) #3477

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion API/Controllers/OPDSController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ public async Task<ActionResult> GetPageStreamedImage(string apiKey, [FromQuery]

try
{
var path = _cacheService.GetCachedPagePath(chapter.Id, pageNumber);
var path = await GetPage(chapterId, pageNumber);
if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path))
return BadRequest(await _localizationService.Translate(userId, "no-image-for-page", pageNumber));

Expand Down Expand Up @@ -1360,4 +1360,16 @@ private string SerializeXml(Feed? feed)

return sm.ToString().Replace("utf-16", "utf-8"); // Chunky cannot accept UTF-16 feeds
}

private async Task<String> GetPage(int chapterId, int pageNumber)
{
var path = _cacheService.GetCachedPagePath(chapterId, pageNumber);
if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path))
{
_cacheService.CleanupChapters([chapterId]);
await _cacheService.Ensure(chapterId, true);
}

return _cacheService.GetCachedPagePath(chapterId, pageNumber);
}
}