Compare commits

...

2 commits

Author SHA1 Message Date
Kovid Goyal
5fe9010e74
... 2022-03-14 20:11:35 +05:30
Kovid Goyal
f8f971d208
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.
2022-03-14 20:09:05 +05:30

View file

@ -437,6 +437,11 @@ def on_complete(end_type, xhr, ev):
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,17 @@ def start_download(fname, path):
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
# Chrome starts killing AJAX requests if there are too many in flight, unlike Firefox
# which is smart enough to queue them
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):