From f8f971d2084379534ec08c5b8d54e5f0dddc9a7c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 14 Mar 2022 20:09:05 +0530 Subject: [PATCH] Content server: Fix reading of books with thousands of internal files not working in the Chrome browser. Fixes #1964742 [Error when opening EPUB file which contains many chapters via Web Interface](https://bugs.launchpad.net/calibre/+bug/1964742) Apparently chrome's network stack is too dumb to queue multiple ajax requests so do it in our code. --- src/pyj/read_book/ui.pyj | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/ui.pyj b/src/pyj/read_book/ui.pyj index ef8306e41d..d7dbb6f463 100644 --- a/src/pyj/read_book/ui.pyj +++ b/src/pyj/read_book/ui.pyj @@ -437,6 +437,11 @@ class ReadUI: self.downloads_in_progress.remove(xhr) progress_track[this] = raster_cover_size if this is raster_cover_name else files[this].size update_progress() + if len(queued): + for fname in queued: + start_download(fname, base_path + encodeURIComponent(fname).replace(/%2[fF]/g, '/')) + queued.discard(fname) + break if end_type is 'abort': files_left.discard(this) return @@ -469,9 +474,15 @@ class ReadUI: if raster_cover_name: start_download(raster_cover_name, 'get/cover/' + book_id + '/' + encodeURIComponent(library_id)) + count = 0 + queued = set() for fname in files_left: if fname is not raster_cover_name: - start_download(fname, base_path + encodeURIComponent(fname).replace(/%2[fF]/g, '/')) + count += 1 + if count < 20: + start_download(fname, base_path + encodeURIComponent(fname).replace(/%2[fF]/g, '/')) + else: + queued.add(fname) def ensure_maths(self, proceed): self.db.get_mathjax_info(def(mathjax_info):