New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Prevent statistics for a folder with documents #10308
Comments
I like this idea; it's also very useful when previewing books from the Downloads directory. Another thing to consider is to also not record them in the History. However, user preferences may vary on this one. |
+1 |
A bit too niche for us to spend time thinking about a UI to allow flagging/managing/displaying such directories - and as you both agree, users may want some things or some others disabled/changed, so again hard to propose via the UI. I haven't yet tried user-patching plugins, so I don't know how one could hack the statistics plugin. But one thing is that statistics are disabled for PicDocument (that is: images viewed as a document), and the only check is for Something like this may work: local DocumentRegistry = require("document/documentregistry")
local util = require("util")
local orig_openDocument = DocumentRegistry.openDocument
DocumentRegistry.openDocument = function(self, file, provider)
local doc = orig_openDocument(self, file, provider)
if doc and util.stringStartsWith(file, "/koreader_stuff/test/Wikipedia/") then
doc.is_pic = true
end
return doc
end |
This seems to work fine, thank you! For my purposes, I just replaced line 7 with
Question: is it also possible to prevent KOReader from creating a Docsettings file when opening a file from a certain folder with a user patch like this? So that it will just use standard settings and not save any changes? |
I have a look next days. Thank you. |
By overridding the function at the bottom of this snippet, knowing what the end of the :open() function at its top does: koreader/frontend/docsettings.lua Lines 202 to 208 in 99265ba
Not tested, but this may work: local DocSettings = require("docsettings")
local util = require("util")
local orig_flush = DocSettings.flush
function DocSettings:flush(data)
if self and self.data and self.data.doc_path and util.stringStartsWith(self.data.doc_path, "/storage/emulated/0/Download/") then
return
end
orig_flush(self, data)
end |
Thank you, but unfortunately it didn't work. KOReader opens fine but crashes upon exit. It doesn't create a docsettings file (no matter from which directory a file was opened). This is the crash.log:
If you feel like diagnosing the problem then I would welcome that of course. But if not, don't worry about it since this is technically beyond the scope of this ticket. |
Forgot to add |
Amazing, it worked! Thank you! Now if there's also a way to suppress a History record for files in that folder that would be even greater :) :) |
You may be able to catch that third fish by yourself?: koreader/frontend/readhistory.lua Lines 248 to 251 in 99265ba
|
No ? :/ local ReadHistory = require("readhistory")
local util = require("util")
local orig_addItem = ReadHistory.addItem
function ReadHistory:addItem(file, ts, no_flush)
if file ~= nil and util.stringStartsWith(file, "/storage/emulated/0/Download/") then
return
end
orig_addItem(self, file, ts, no_flush)
end |
Thank you! I was going to try and figure it out myself, but I needed some more time. I definitely appreciate the education! 👍 Edit: Tested and it works! Thanks again. |
Thanks it works!! |
In newer version (android 2024.01.63), I used these patches, when open a document, it still created new entry at statistics.sqlite3 although didn't update stats of this file (read time, etc...). Could I somehow prevent unused entry be created? |
thread at Mobilereads for the backgroundinfos:
https://www.mobileread.com/forums/showthread.php?t=353241
I have a folder structure on my Kindle:
/documents
/documnts/books
/documnts/books/done
/documnts/music
in "/documnts/books" and "/documnts/books/done" are epub books.
In "/dokumnts/music" are (PDF) sheet music to sing. I would like to exclude all data in the folder "/dokumnts/music" from the statistics plugin.
Is there a way to do this?
The text was updated successfully, but these errors were encountered: