Including the archive dir in the result of Wallabag:getLocalArticles
causes all archived articles' statuses to be synced with Wallabag every
time. That leads to an increase in sync times from seconds to minutes
(or even more if one's archive is larger than hundreds…).
The fix is simple: skip the archive dir when scanning.
(As a side effect, this allows one to organise their archive dir using
subdirs, which is similar to the motivation of the PR that broke this…)
Fixes: 896646bf8b ("Reworked the Wallabag plugin to recursively scan the download directory (#15558)")
Fixes: https://github.com/koreader/koreader/pull/15558#issuecomment-5136923551
The previous handling had two problems:
- current dir only appended if argc == 1
- multiple args passed as one to reader.lua
As a result:
- `bin/koreader -v -d` doesn't work (reader.lua sees it as one arg)
- `bin/koreader -d abc.epub` doesn't work either (for the same reason)
The fix is to go through args one by one and use `set -- …` to keep them
as an array of args (preserves white-space and avoid unintended
expansions that might happen if we attempted to do some eval trickery
instead).
Note that reader.lua doesn't currently handle multiple file/dir args, so
we could instead just look at the last arg and add pwd to that one.
Unfortunately doing this in POSIX sh isn't any simpler than processing
all args. :-)
(While at it, use `$PWD` which is required by POSIX to always be
present.)
Tested with bash 5.3.9, busybox 1.37.0 and dash 0.5.12.
Creating the cover image delays rotation a little bit (half a second,
even if cached), although it could be several seconds on some PocketBook
devices since #14985 which synchronously invokes `sync` after creating
the cover.
To work around this, skip creating the image in the onSetRotationMode
event hook if "Rotate image" is disabled as the resulting image would be
exactly the same. The speedup is noticeable even if the cover cache gets
hit.
(The issue with synchronous `sync` taking several seconds will be fixed
later once we figure out whether any PocketBook devices actually need
the `sync` or not.)
Related: https://github.com/koreader/koreader/issues/15177
Related: https://github.com/koreader/koreader/pull/14985
Many PocketBook devices include a web browser, but when clicking a link in KOReader, there was no option to open the link in the browser, there was only an option to show a QR code (which can then be scanned by a smartphone).
This commit implements `canOpenLink`/`openLink` on PocketBook using the "browser.app", if available.
Tested on PB740 (InkPad 3).
Fixes: https://github.com/koreader/koreader/issues/11782
Related: https://github.com/koreader/koreader/issues/6597
Device:getDefaultRoute parses /proc/net/route and converts the hex
addresses to textual IP addresses, but in `isOnline` we don't care what
address the gateway actually has, we only care about whether we have a
default route into the Internet.
This provides a simpler alternative that does the equivalent of
"ip route get 203.0.113.1 || ip route get 2001:db8::1" (note that it
does support IPv6-only connectivity as opposed to
Device:getDefaultRoute) and returns true if we have a route.
Inspired by https://github.com/pavel-odintsov/get_default_outgoing_ip_linux
Doing the `isOnline` check (`socket.dns.toip("dns.msftncsi.com")`)
without having internet connectivity (`!isConnected`) results in the
`isOnline` check never succeeding again even if connectivity is later
acquired. This is most likely caused by /etc/resolv.conf only being
parsed once - https://sourceware.org/bugzilla/show_bug.cgi?id=984, an
issue that was fixed in glibc 2.26 (PocketBook firmware U740.6.8.2461
has glibc 2.23).
This fix works around the problem by checking if we have a default route
first before even attempting to check `isOnline`. If we don't, then
`isOnline` is (almost) guaranteed to fail anyway.
We could alternatively check `isConnected` instead, but that only checks
wireless connectivity on many platforms, and we could have internet
access via USBNet instead. Checking for the default route via any
interface should work reliably for both wireless and USBNet
connectivity.
Another alternative fix is to add a fallback nameserver to
/etc/resolv.conf like we do for the Kobo platform [1]. Unfortunately,
this fix would not work in the following (rather common) scenario:
1. PocketBook boots, connects to WiFi
2. KOReader starts, /etc/resolv.conf looks all right, no fallback needed
3. PocketBook goes to sleep, disconnects from WiFi, clears resolv.conf
4. PocketBook wakes up, stays disconnected
5. KOReader user does a Wikipedia lookup, networking freezes
[1]: https://github.com/koreader/koreader/pull/6424/files#diff-be863601c59a2d6607af6b04b3be2392ec4494df6d25dae48250fae57b737f61R216-R224
Fixes: https://github.com/koreader/koreader/issues/10183
Related: https://github.com/koreader/koreader/issues/6421