Commit Graph

66 Commits (master)

Author SHA1 Message Date
hius07 c3bb2263b7
DocSettings: check legacy history location only once (#11439) 2 months ago
NiLuJe de3e420c1e DocSettings: Abort early if doc_path is nil or empty in findSidecarFile
Regression from #11020 compared to the previous getSidecarFile behavior
3 months ago
hius07 b70f866656
DocSettings (again) (#11020)
Cleaning and optimizing Docsettings code.
6 months ago
hius07 c92d94af4d
writeToFile: centralize (#11012) 6 months ago
hius07 2ed2c2c23d
md5: centralize and deduplicate (#11003)
Document partial md5 hash is calculated by util.partialMD5() and stored in doc_settings as "partial_md5_checksum" on the first document opening.
6 months ago
Ryan W West 27104ea011
Add hash-based document metadata storage option (#10945)
This option saves metadata sidecar (sdr) directories not next to the book or in koreader/docsettings/, but in koreader/hashdocsettings/ using the partial md5 hash of each documents, allowing users to move, rename, and copy their documents outside of KOReader without accidentally losing their highlights/notes/progress. Included are various warnings and info to users of the benefits and drawbacks of this non-default option.

Closes #10892.
6 months ago
NiLuJe ba5c7df0db DocSettings: Minor cleanup following #10861
Allows me to fix an old pet-peeve of mine re: the terrible variable
names used in there ;o).
7 months ago
hius07 f46f341b9b
Reset settings/cover/metadata separately (#10866) 7 months ago
hius07 ed2ea6803f
Custom metadata (#10861) 8 months ago
hius07 46933035c5
Open with: images (#10561) 10 months ago
hius07 1944f54aa0
Custom cover: fix (#10513)
Somehow have overlooked in testing.
Closes #10512.
11 months ago
hius07 4f23a6fafa
Custom book covers (#10329) 12 months ago
hius07 38bd768d5e
DocSettings: Move book metadata to preferred location (#10149) 1 year ago
hius07 d1081fa982
Docsettings: add centralized sdr storage (#10074)
Added an option to choose a new location to save document settings, highlights and bookmarks 
(koreader/docsettings folder).
1 year ago
NiLuJe 3a8e9f0333 DocSettings: Refine the primary/backup mtime shenanigans
Use the same mtime (the newest) for both entries, so that priority order
wins the tie, giving priority to the primary.

Avoids preferring an older legacy sidecar in case of issues with the new
files.
1 year ago
NiLuJe 1ca0748ca7 DocSettings: Make sure that between a main/backup pair of sidecar files,
the main one *always* has priority, regardless of mtime.

Should help workaround weird local/UTC issues when USBMS is involved,
c.f., https://github.com/koreader/koreader/issues/9227#issuecomment-1345263324
1 year ago
NiLuJe c9ff0071e3
DocSettings: Fix candidates sorting (#9607)
The candidates array had a very very very high chance of being sparse, which effectively broke the logic.
It was mostly harmless since said logic is only here for a long and varied history of backwards compatibility ;).
2 years ago
NiLuJe 5c24470ea9
Logger: Use serpent instead of dump (#9588)
* Persist: support serpent, and use by default over dump (as we assume consistency > readability in Persist).
* Logger/Dbg: Use serpent instead of dump to dump tables (it's slightly more compact, honors __tostring, and will tag tables with their ref, which can come in handy when debugging).
* Dbg: Don't duplicate Logger's log function, just use it directly.
* Fontlist/ConfigDialog: Use serpent for the debug dump.
* Call `os.setlocale(C, "numeric")` on startup instead of peppering it around dump calls. It's process-wide, so it didn't make much sense.
* Trapper: Use LuaJIT's serde facilities instead of dump. They're more reliable in the face of funky input, much faster, and in this case, the data never makes it to human eyes, so a human-readable format didn't gain us anything.
2 years ago
NiLuJe fadee1f5dc
Clarify our OOP semantics across the codebase (#9586)
Basically:

* Use `extend` for class definitions
* Use `new` for object instantiations

That includes some minor code cleanups along the way:

* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
  * ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2 years ago
hius07 13d80739b6
docsettings fix no name file (#8517)
When trying to open/delete a supported document with empty name (eg .txt) got an error

./luajit: frontend/docsettings.lua:118: attempt to concatenate a nil value
2 years ago
poire-z 1004081098
DocSettings: fix settings not saved when book on read-only FS (#8448)
Witnessed on Android with books on the external SD card.
2 years ago
poire-z 37eb53f6e4
DocSettings/Purge .sdr: reword, don't purge other books (#8348)
Reword "Purge .sdr" to "Reset settings".
When purging, remove only the known document metadata
files, and not those for a document with the same name but
a different suffix.
3 years ago
NiLuJe bf6c0cdd6c
LuaSettings: Add a method to initialize a setting properly (#7371)
* LuaSettings/DocSettings: Updated readSetting API to allow proper initialization to default.
Use it to initialize tables, e.g., fixing corner-cases in readerFooter that could prevent settings from being saved.
(Fixes an issue reported on Gitter).
* LuaSettings/DocSettings: Add simpler API than the the flip* ones to toggle boolean settings.
* Update LuaSettings/DocSettigns usage throughout the codebase to use the dedicated boolean methods wher appropriate, and clean up some of the more mind-bending uses.
* FileChooser: Implement an extended default exclusion list (fix #2360)
* ScreenSaver: Refactor to avoid the pile of kludges this was threatening to become. Code should be easier to follow and use, and fallbacks now behave as expected (fix #4418).
3 years ago
poire-z cfa45f8d88 History: show last read date instead of file size
In classic and list display modes.
4 years ago
poire-z 5a4f5b4d59 bump crengine, migrate books to normalized xpointers
Enable new rendering feature COMPLETE_INCOMPLETE_TABLES
on all enhanced rendering mode, but have it disabled for
earlier cre_dom_version.
Also increase default_cre_storage_size_factor from 20 to 40.
4 years ago
poire-z 04d9a557aa Use fsync() for more robust setting files saving
Bump base for util.fsyncOpenedFile() and util.fsyncDirectory().

Use these to force flush to storage device when
saving luasetting, docsetting, and history.lua.
Also dont rotate them to .old until they are at least
60 seconds old.
Also make auto_save_paging_count count right.

Also bump crengine: open (as text) small or empty files
4 years ago
Frans de Jonge a2dcfe9aec
[doc] Tag @todo, @fixme and @warning (#5244)
This commit standardizes the various todos around the code a bit in a manner recognized by LDoc.

Besides drawing more attention by being displayed in the developer docs, they're also extractable with LDoc on the command line:

```sh
ldoc --tags todo,fixme *.lua
```

However, whether that particular usage offers any advantage over other search tools is questionable at best.

* and some random beautification
5 years ago
poire-z bb949afb7f
Fix crash and History with books in read-only directories (#4138)
docsettings can be stored either as a sidecar file (prefered, when
possible), or as a .lua file in the koreader/history/ folder (good,
when book is in a read-only directory where we can't create the
.sdr/ directory).
They are managed correctly if for some reason, the book directory
becomes writable: the docsettings in history/ is read, used, and
removed when a docsetting in a .sdr/ can be saved.
These docsettings in koreader/history/ contribute to the History
list build: they are put it in history.lua, and the duplicates
on followups history.lua builds are removed.

This fix a crash when a book is in a read-only directory.
Also fix History containing strange entries like "Book.epub.lua",
that came from the koreader/history/book.epub.lua.old backup,
that weren't removed as they are not a duplicate.
6 years ago
Hzj_jie 7461e396dd [chore] Ignore empty files and tables in DocSettings (#3348) 7 years ago
Zijie He 2ba079e3eb Reserve last good docsetting 7 years ago
Frans de Jonge 96d4adb34c Docs: DocSettings (#2763) 7 years ago
Hzj_jie 0b29e73e2e BatteryStat plugin and instruction of KoboLight plugin (#2643)
* Start battery stat plugin

* BatteryStat & kobolight

* Several minor improvements

* Remove a useless function

* flush settings

* Some review feedbacks

* Resolve review comments

* Remaining Minutes -> Remaining Hours

* Add dump_file

* typo

* realpath

* realpath on folder

* Remove useless os.time()

* Resolve review comments

* warning

* Add BatteryStat.debugging flag

* treat log as txt

* Minor improvement

* Charging hour should be positive

* Use warn instead of info

* onSuspend in Kobo

* Charging events for kobo and kindle

* More events

* dumpOrLog

* Warnings

* Typo

* More space

* Singleton

* slightly format change

* BatteryStat singleton

* Init

* Remove debugging flag

* sleeping percentage is still negative

* Read settings

* Do not need to change was_suspending and was_charging

* Typo

* Remove debugging flag

* Not charging should happen before suspend

* Resolve review comments

* was_suspend and was_charging should be updated each time in onCallback()
7 years ago
Qingping Hou 2aa9d5d64e test: add unit tests for docsettings 7 years ago
Zijie He 83d8606270 Crash on directory 7 years ago
Zijie He b502047635 Removing metadata file instead of purging .sdr folder 7 years ago
poire-z 8f6a38db69 Fix sidecar file name
Get back "metadata." part forgotten while refactoring.
7 years ago
Hzj_jie 529d1b3d33 evernote: ReadHistory integration and text file output (#2498) 7 years ago
poire-z 0aa19d72a0 FileManager: show files with sidecar dir in bold (#2391)
docsettings : added hasSidecarDir() and made getSidecarDir() more robust
widget/menu : allow items to specify themselves to be displayed in bold
7 years ago
Zijie He ced671bc69 Add readhistory_spec / docsettings_spec 8 years ago
Hzj_jie 7493fc89f6 Add removed item name in "Remove this item from history" and fix wrong items deleted issue. (#2164)
* Add removed item name in "Remove this item from history".

* Fix #2162, wrong history items deleted.
8 years ago
Qingping Hou 20eb36a03d feat: add network management UI for kobo 8 years ago
Hzj_jie cf8c0aa81f Add docsettings unittest 8 years ago
Hzj_jie 016aaa92b9 Merge remote-tracking branch 'upstream/master'
Conflicts:
	frontend/docsettings.lua
8 years ago
Hzj_jie 2085b774e2 Remove legacy document settings after flushing. 8 years ago
Qingping Hou 2e417cfbd8 filemanager(refactor): use purge method from docsettings 8 years ago
Zijie He 4f897acc67 Refine docsettings, does not write history folder if it's not necessary. 8 years ago
Zijie He 667e8834ad Migrate history folder, FileManagerHistory uses own history.lua file and ReadHistory component 8 years ago
Frans de Jonge 5638819f25 Removed a bunch of "successfully", replaced an ellipsis, and some deviant spellings of KOReader. 8 years ago
Zijie He ccd95b80fa Prefer sdr folder to history folder 8 years ago
Qingping Hou e5c1ff1ef6 test(bookmark): purge doc settings before test 8 years ago