* [PATCH 4/7] net_reader: imap_each: add UIDVALIDITY to URL arg
2021-04-24 9:28 7% [PATCH 0/7] lei sync preparations, "lei inspect" Eric Wong
@ 2021-04-24 9:28 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-04-24 9:28 UTC (permalink / raw)
To: meta
This will allow the callback to reliably maintain OID <=> UID
mappings between lei/store and the IMAP folder.
---
lib/PublicInbox/NetReader.pm | 11 +++++++----
t/net_reader-imap.t | 4 +++-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index 39129b34..5978752f 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -347,7 +347,7 @@ sub errors {
}
sub _imap_do_msg ($$$$$) {
- my ($self, $uri, $uid, $raw, $flags) = @_;
+ my ($self, $url, $uid, $raw, $flags) = @_;
# our target audience expects LF-only, save storage
$$raw =~ s/\r\n/\n/sg;
my $kw = [];
@@ -358,12 +358,12 @@ sub _imap_do_msg ($$$$$) {
} elsif ($f eq "\\Deleted") { # not in JMAP
return;
} elsif ($self->{verbose}) {
- warn "# unknown IMAP flag $f <$uri;uid=$uid>\n";
+ warn "# unknown IMAP flag $f <$url/;UID=$uid>\n";
}
}
@$kw = sort @$kw; # for all UI/UX purposes
my ($eml_cb, @args) = @{$self->{eml_each}};
- $eml_cb->($uri, $uid, $kw, PublicInbox::Eml->new($raw), @args);
+ $eml_cb->($url, $uid, $kw, PublicInbox::Eml->new($raw), @args);
}
sub run_commit_cb ($) {
@@ -396,6 +396,9 @@ sub _imap_fetch_all ($$$) {
return "E: $uri cannot get UIDVALIDITY";
$r_uidnext //= $mic->uidnext($mbx) //
return "E: $uri cannot get UIDNEXT";
+ my $url = ref($uri)->new($$uri);
+ $url->uidvalidity($r_uidval);
+ $url = $$url;
my $itrk = _itrk($self, $uri);
my $l_uid;
$l_uid = $itrk->get_last($r_uidval) if $itrk;
@@ -455,7 +458,7 @@ sub _imap_fetch_all ($$$) {
# messages get deleted, so holes appear
my $per_uid = delete $r->{$uid} // next;
my $raw = delete($per_uid->{$key}) // next;
- _imap_do_msg($self, $uri, $uid, \$raw,
+ _imap_do_msg($self, $url, $uid, \$raw,
$per_uid->{FLAGS});
$last_uid = $uid;
last if $self->{quit};
diff --git a/t/net_reader-imap.t b/t/net_reader-imap.t
index e478ee07..5de8f92b 100644
--- a/t/net_reader-imap.t
+++ b/t/net_reader-imap.t
@@ -33,7 +33,9 @@ is(scalar(@w), 0, 'no warnings');
ok($nr, 'got some emails');
is($eml{'PublicInbox::Eml'}, $nr, 'got expected Eml objects');
is(scalar keys %eml, 1, 'only got Eml objects');
-is($urls{$url}, $nr, 'one URL expected number of times');
+is(scalar(grep(/\A\Q$url\E;UIDVALIDITY=\d+\z/, keys %urls)), scalar(keys %urls),
+ 'UIDVALIDITY added to URL passed to callback');
+is_deeply([values %urls], [$nr], 'one URL expected number of times');
is(scalar keys %urls, 1, 'only got one URL');
is($args{blah}, $nr, 'got arg expected number of times');
is(scalar keys %args, 1, 'only got one arg');
^ permalink raw reply related [relevance 6%]
* [PATCH 0/7] lei sync preparations, "lei inspect"
@ 2021-04-24 9:28 7% Eric Wong
2021-04-24 9:28 6% ` [PATCH 4/7] net_reader: imap_each: add UIDVALIDITY to URL arg Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-04-24 9:28 UTC (permalink / raw)
To: meta
"lei import" now tracks IMAP and Maildir source information in
preparation for propagating keywords back to IMAP|Maildir.
"lei inspect" is a long-overdue debug/diagnostic thing.
Eric Wong (7):
lei_input: drop outdated comment w.r.t. compression
t/lei_to_mail: split "lei import" test $HOME directory
URIimap: support ->uidvalidity and ->iuid
net_reader: imap_each: add UIDVALIDITY to URL arg
doc: lei_design_notes: add a bit on WAL usage
lei_mail_sync: for bidirectional keyword sync
lei import: keep sync info for Maildir and IMAP folders
Documentation/lei_design_notes.txt | 12 ++
MANIFEST | 3 +
lib/PublicInbox/LEI.pm | 16 ++-
lib/PublicInbox/LeiImport.pm | 22 ++-
lib/PublicInbox/LeiInput.pm | 42 +++++-
lib/PublicInbox/LeiInspect.pm | 96 +++++++++++++
lib/PublicInbox/LeiMailSync.pm | 211 +++++++++++++++++++++++++++++
lib/PublicInbox/LeiSearch.pm | 7 +
lib/PublicInbox/LeiStore.pm | 20 ++-
lib/PublicInbox/NetReader.pm | 11 +-
lib/PublicInbox/TestCommon.pm | 2 +
lib/PublicInbox/URIimap.pm | 38 +++++-
t/lei-import-imap.t | 27 +++-
t/lei-import-maildir.t | 21 +++
t/lei_mail_sync.t | 68 ++++++++++
t/lei_to_mail.t | 8 +-
t/net_reader-imap.t | 4 +-
t/uri_imap.t | 32 ++++-
18 files changed, 612 insertions(+), 28 deletions(-)
create mode 100644 lib/PublicInbox/LeiInspect.pm
create mode 100644 lib/PublicInbox/LeiMailSync.pm
create mode 100644 t/lei_mail_sync.t
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-04-24 9:28 7% [PATCH 0/7] lei sync preparations, "lei inspect" Eric Wong
2021-04-24 9:28 6% ` [PATCH 4/7] net_reader: imap_each: add UIDVALIDITY to URL arg Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).