diff options
author | Eric Wong <e@80x24.org> | 2021-06-09 22:39:24 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-06-10 09:21:01 +0000 |
commit | 59be5c57763a64c04ecbb9a344b60c435a43fb24 (patch) | |
tree | be1f978f52bfbafdabeab6fcecc821f2d4035fda /lib/PublicInbox/LeiImport.pm | |
parent | 84cc78416994832973c44aab08814b43a0fe7e51 (diff) | |
download | public-inbox-59be5c57763a64c04ecbb9a344b60c435a43fb24.tar.gz |
Taking ~40s to synchronize a ~75K message IMAP folder is still a lot of time, so support an option to only touch new messages. This is similar to "offlineimap -q" (quick) or "mbsync --new" switches, but lei already accepts "-q" as a shortcut for --quiet. "--new" could work, but "--new-only" might be more descriptive (or "--only-new"?), since the default fetches also fetches new messages. v2: warn for non-IMAP sources, I'm not sure it's worth it for Maildir or other sources, yet. It will also make sense for MH and JMAP once we support them.
Diffstat (limited to 'lib/PublicInbox/LeiImport.pm')
-rw-r--r-- | lib/PublicInbox/LeiImport.pm | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index e3cb69ca..08794f71 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -78,12 +78,14 @@ sub do_import_index ($$@) { $j =~ /\A([0-9]+),[0-9]+\z/ and $j = $1 + 0; $j ||= scalar(@{$self->{inputs}}) || 1; my $ikw; - if (my $net = $lei->{net}) { + my $net = $lei->{net}; + if ($net) { # $j = $net->net_concurrency($j); TODO if ($lei->{opt}->{incremental} // 1) { $net->{incremental} = 1; $net->{-lms_ro} = $sto->search->lms // 0; if ($self->{-import_kw} && $net->{-lms_ro} && + !$lei->{opt}->{'new-only'} && $net->{imap_order}) { require PublicInbox::LeiImportKw; $ikw = PublicInbox::LeiImportKw->new($lei); @@ -94,6 +96,9 @@ sub do_import_index ($$@) { my $nproc = $self->detect_nproc; $j = $nproc if $j > $nproc; } + if ($lei->{opt}->{'new-only'} && (!$net || !$net->{imap_order})) { + $lei->err('# --new-only is only for IMAP'); + } my $ops = {}; $lei->{auth}->op_merge($ops, $self) if $lei->{auth}; $self->{-wq_nr_workers} = $j // 1; # locked |