about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAPTracker.pm
DateCommit message (Collapse)
2021-08-11treewide: use *nix-specific dirname regexps
None of our code elsewhere accounts for non-*nix pathnames and it's not worth our time to start. So stop wasting CPU cycles giving the illusion that we'd care about non-*nix pathnames.
2021-04-30lei import: avoid IMAPTracker, use LeiMailSync more
IMAPTracker has a UNIQUE constraint on the `url' column, which may cause compatibility and/or rollback problems in attempting to deal with UIDVALIDITY changes. Having multiple sources of truth leads to confusion and bugs, so relying on LeiMailSync exclusively ought to simplify things. Furthermore, since LeiMailSync is only written to by LeiStore, it is safer in that it won't mark a UID or article as imported until git-fast-import has seen it, and the SQLite commit always happens after "done\n" is sent to fast-import. This mostly reverts recent commits to IMAPTracker to support lei, those are: 1) commit 7632d8f7590daf70c65d4270e750c36552fa9389 ("net_reader: restart on first UID when UIDVALIDITY changes") 2) commit 311a5d37ad275cd75b1e64d87827c4d13fe4bfab ("imap_tracker: prepare for use with lei"). This means public-inbox-watch will not change between 1.6 and 1.7: -watch stops synching a folder when UIDVALIDITY changes.
2021-04-23net_reader: restart on first UID when UIDVALIDITY changes
In other words, treat the same IMAP folder with a different UIDVALIDITY as a completely different folder. If the UIDVALIDITY changes, we can start from UID=1 without falling behind or losing data. If the UIDVALIDITY gets reset to a previously known-good message, we can still resume where we left off before the first UIDVALIDITY change. This affects public-inbox-watch and "lei import" One potential downside of this is for rare altid users, but that's mainly intended for NNTP article numbers which are/were often publicized; not IMAP UIDs which are rarely publicized. The other potential downside is bandwidth waste in in the rare case UIDVALIDITY changes while IMAP folder contents remain unchanged. There's no extra storage used due to existing (v1|v2|lei/store) deduplication mechanisms. Before this change, we were matching offlineimap behavior and stopped synching an IMAP folder when its UIDVALIDITY changed. offlineimap behavior made sense for IMAP <=> Maildir synchronization since Maildirs had no sense of UIDVALIDITY and could only rely on name mapping.
2021-04-22imap_tracker: prepare for use with lei
We'll support nodatacow as we do in other SQLite DBs
2021-01-01update copyrights for 2021
Using "make update-copyrights" after setting GNULIB_PATH in my config.mak
2020-08-28imaptracker: update_last: simplify callers
By making it a no-op if last_uid is not defined. This isn't a hot code path, so the extra method dispatch isn't an issue. It'll save some indentation/wrapping in future commits.
2020-08-27imaptracker: preserve WAL journal_mode if set by user
It's no problem for most users to enable WAL, here, since there's only a single process doing both reading and writing (unlike the read-only daemons). However, WAL doesn't work on network filesystems, so it can't be enabled by default.
2020-06-28imaptracker: use flock(2) around writes
SQLite only issues non-blocking F_SETLK ops (not F_SETLKW) and retries failures using a configurable busy_timeout. SQLite's busy loop sleeps for a millisecond and retries the lock until the configured busy_timeout is hit. Trying to set ->sqlite_busy_timeout to larger values (e.g. 30000 milliseconds) still leads to failure when running the new stress test with 8 processes with TMPDIR on a 7200 RPM HDD. Inspection of SQLite source reveals there's no built-in way to use F_SETLKW, so tack on the existing flock(2) support we use to synchronize git + SQLite + Xapian for inbox writing. We use flock(2) instead of POSIX fcntl(2) locks since Perl doesn't provide a way to manipulate "struct flock" portably.
2020-06-28imaptracker: drop {dbname} field
It's not used anywhere since the IMAPTracker object doesn't disconnect and reconnect. If we ever need the filename, {dbh}->sqlite_db_filename may be used. Cc: Eric W. Biederman <ebiederm@xmission.com>
2020-06-28imaptracker: add {url} field to reduce args
Passing a $url parameter to every function was error-prone and having {url} field for a short-lived object is appropriate. This matches the version of IMAPTracker posted by Eric W. Biederman on 2020-05-15 at: https://public-inbox.org/meta/87ftc0c3r4.fsf_-_@x220.int.ebiederm.org/ The version I originally imported was based on the one posted on 2019-10-09: https://public-inbox.org/meta/874l0i9vhc.fsf_-_@x220.int.ebiederm.org/ Cc: Eric W. Biederman <ebiederm@xmission.com>
2020-06-28imaptracker: use ~/.local/share/public-inbox/imap.sqlite3
Respect XDG_DATA_HOME to avoid cluttering ~/.public-inbox/. Existing users of ~/.public-inbox/imap.sqlite3 will remain supported, but the preference for new data is to use ~/.local/share and other paths standardized by XDG. Cc: "Eric W. Biederman" <ebiederm@xmission.com>
2020-06-28IMAPTracker: Add a helper to track our place in reading imap mailboxes
This removes the need to delete from an imap mailbox when downloading it's messages. [ew: minor style changes] Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>