mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
EPUB: limit image download dismiss check display updates to once per second
Some checks are pending
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (10.15, 13, x86-64, 15.2) (push) Waiting to run
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (11.0, 14, ARM64, 15.4) (push) Waiting to run
Some checks are pending
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (10.15, 13, x86-64, 15.2) (push) Waiting to run
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (11.0, 14, ARM64, 15.4) (push) Waiting to run
On Wikipedia articles with for example 30 images this reduces the download time from ~12 seconds to ~8 seconds (depending on image size and connection speed), which is fairly significant.
This commit is contained in:
committed by
Frans de Jonge
parent
bfa751d063
commit
923b690179
@@ -4,6 +4,7 @@ local Screen = require("device").screen
|
||||
local ffiutil = require("ffi/util")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
local time = require("ui/time")
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local T = ffiutil.template
|
||||
@@ -1503,14 +1504,22 @@ abbr.abbr {
|
||||
-- OEBPS/images/*
|
||||
if include_images then
|
||||
local nb_images = #images
|
||||
local before_images_time = time.now()
|
||||
local time_prev = before_images_time
|
||||
for inum, img in ipairs(images) do
|
||||
-- Process can be interrupted at this point between each image download
|
||||
-- Process can be interrupted every second between image downloads
|
||||
-- by tapping while the InfoMessage is displayed
|
||||
-- We use the fast_refresh option from image #2 for a quicker download
|
||||
local go_on = UI:info(T(_("Retrieving image %1 / %2 …"), inum, nb_images), inum >= 2)
|
||||
if not go_on then
|
||||
cancelled = true
|
||||
break
|
||||
local go_on
|
||||
if time.to_ms(time.since(time_prev)) > 1000 then
|
||||
time_prev = time.now()
|
||||
go_on = UI:info(T(_("Retrieving image %1 / %2 …"), inum, nb_images), inum >= 2)
|
||||
if not go_on then
|
||||
cancelled = true
|
||||
break
|
||||
end
|
||||
else
|
||||
UI:info(T(_("Retrieving image %1 / %2 …"), inum, nb_images), inum >= 2, true)
|
||||
end
|
||||
local src = img.src
|
||||
if use_img_2x and img.src2x then
|
||||
@@ -1539,6 +1548,7 @@ abbr.abbr {
|
||||
end
|
||||
end
|
||||
end
|
||||
logger.dbg("Image download time for:", page_htmltitle, time.to_ms(time.since(before_images_time)), "ms")
|
||||
end
|
||||
|
||||
-- Done with adding files
|
||||
|
||||
@@ -7,6 +7,7 @@ local ltn12 = require("ltn12")
|
||||
local socket = require("socket")
|
||||
local socket_url = require("socket.url")
|
||||
local socketutil = require("socketutil")
|
||||
local time = require("ui/time")
|
||||
local _ = require("gettext")
|
||||
local T = ffiutil.template
|
||||
|
||||
@@ -574,14 +575,22 @@ function EpubDownloadBackend:createEpub(epub_path, html, url, include_images, me
|
||||
-- OEBPS/images/*
|
||||
if include_images then
|
||||
local nb_images = #images
|
||||
local before_images_time = time.now()
|
||||
local time_prev = before_images_time
|
||||
for inum, img in ipairs(images) do
|
||||
-- Process can be interrupted at this point between each image download
|
||||
-- Process can be interrupted every second between image downloads
|
||||
-- by tapping while the InfoMessage is displayed
|
||||
-- We use the fast_refresh option from image #2 for a quicker download
|
||||
local go_on = UI:info((message and message ~= "" and message .. "\n\n" or "") .. T(_("Retrieving image %1 / %2 …"), inum, nb_images), inum >= 2)
|
||||
if not go_on then
|
||||
cancelled = true
|
||||
break
|
||||
local go_on
|
||||
if time.to_ms(time.since(time_prev)) > 1000 then
|
||||
time_prev = time.now()
|
||||
go_on = UI:info((message and message ~= "" and message .. "\n\n" or "") .. T(_("Retrieving image %1 / %2 …"), inum, nb_images), inum >= 2)
|
||||
if not go_on then
|
||||
cancelled = true
|
||||
break
|
||||
end
|
||||
else
|
||||
UI:info((message and message ~= "" and message .. "\n\n" or "") .. T(_("Retrieving image %1 / %2 …"), inum, nb_images), inum >= 2, true)
|
||||
end
|
||||
local src = img.src
|
||||
if use_img_2x and img.src2x then
|
||||
@@ -610,6 +619,7 @@ function EpubDownloadBackend:createEpub(epub_path, html, url, include_images, me
|
||||
end
|
||||
end
|
||||
end
|
||||
logger.dbg("Image download time for:", page_htmltitle, time.to_ms(time.since(before_images_time)), "ms")
|
||||
end
|
||||
|
||||
-- Done with adding files
|
||||
|
||||
Reference in New Issue
Block a user