Skip to content

Commit

Permalink
Download page files for book publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
umerfaruk committed Sep 6, 2024
1 parent c2bc78d commit 263b12a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public PublishBookRequestHandler(IBookRepository bookRepository,
foreach (var chapter in chapters)
{
var pages = await _bookPageRepository.GetPagesByBookChapter(command.LibraryId, command.BookId, chapter.Id, cancellationToken);
var finalText = CombinePages(pages);
var finalText = await CombinePages(pages, cancellationToken);
chapterText.Add(finalText);
if (chapter.Contents.Any(cc => cc.Language == book.Language))
{
Expand Down Expand Up @@ -123,7 +123,7 @@ private async Task UpdateFileInStorage(BookModel book, long fileId, byte[] file,

private char[] pageBreakSymbols = new char[] { '۔', ':', '“', '"', '\'', '!' };

private string CombinePages(IEnumerable<BookPageModel> pages)
private async Task<string> CombinePages(IEnumerable<BookPageModel> pages, CancellationToken cancellationToken)
{
StringBuilder builder = new StringBuilder();

Expand All @@ -135,6 +135,14 @@ private string CombinePages(IEnumerable<BookPageModel> pages)
}

var separator = " ";
if (page.ContentId.HasValue)
{
var file = await _fileRepository.GetFileById(page.ContentId.Value, cancellationToken);
if (file != null)
{
page.Text = await _fileStorage.GetTextFile(file.FilePath, cancellationToken);
}
}
var finalText = page.Text.Trim();
var lastCharacter = finalText.Last();

Expand Down

0 comments on commit 263b12a

Please sign in to comment.