mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
AutoSave: Delay I/O until after the pageturn (#6917)
nextTick was too early ;). Prevents small hitches when turning the page for the page where this triggers. Apply the same trickery to the Stats DB insert, even if that one probably had a much smaller impact.
This commit is contained in:
@@ -967,10 +967,12 @@ function ReaderView:checkAutoSaveSettings()
|
||||
if not interval then -- no auto save
|
||||
return
|
||||
end
|
||||
|
||||
local now_ts = os.time()
|
||||
if now_ts - self.settings_last_save_ts >= interval*60 then
|
||||
self.settings_last_save_ts = now_ts
|
||||
UIManager:nextTick(function()
|
||||
-- I/O, delay until after the pageturn
|
||||
UIManager:tickAfterNext(function()
|
||||
self.ui:saveSettings()
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -2173,8 +2173,12 @@ function ReaderStatistics:onPageUpdate(pageno)
|
||||
|
||||
-- We want a flush to db every 50 page turns
|
||||
if self.pageturn_count >= MAX_PAGETURNS_BEFORE_FLUSH then
|
||||
self:insertDB(self.id_curr_book)
|
||||
-- insertDB will call resetVolatileStats for us ;)
|
||||
-- I/O, delay until after the pageturn, but reset the count now, to avoid potentially scheduling multiple inserts...
|
||||
self.pageturn_count = 0
|
||||
UIManager:tickAfterNext(function()
|
||||
self:insertDB(self.id_curr_book)
|
||||
-- insertDB will call resetVolatileStats for us ;)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Update average time per page (if need be, insertDB will have updated the totals and cleared the volatiles)
|
||||
|
||||
Reference in New Issue
Block a user