* [PATCH 4/5] lei_mail_sync: hoist out --all handling from export-kw
2021-06-09 7:47 6% [PATCH 0/5] lei Maildir stuff Eric Wong
@ 2021-06-09 7:47 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-06-09 7:47 UTC (permalink / raw)
To: meta
We'll be reusing it in other commands, too.
---
lib/PublicInbox/LeiExportKw.pm | 32 ++----------------------------
lib/PublicInbox/LeiMailSync.pm | 36 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm
index f8579221..671a84df 100644
--- a/lib/PublicInbox/LeiExportKw.pm
+++ b/lib/PublicInbox/LeiExportKw.pm
@@ -94,36 +94,8 @@ EOM
lei mail_sync uninitialized, see lei-import(1)
EOM
my $opt = $lei->{opt};
- my $all = $opt->{all};
- if (defined $all) { # --all=<local|remote>
- my %x = map { $_ => $_ } split(/,/, $all);
- my @ok = grep(defined, delete(@x{qw(local remote), ''}));
- my @no = keys %x;
- if (@no) {
- @no = (join(',', @no));
- return $lei->fail(<<EOM);
---all=@no not accepted (must be `local' and/or `remote')
-EOM
- }
- my (%seen, @inc);
- my @all = $lms->folders;
- for my $ok (@ok) {
- if ($ok eq 'local') {
- @inc = grep(!m!\A[a-z0-9\+]+://!i, @all);
- } elsif ($ok eq 'remote') {
- @inc = grep(m!\A[a-z0-9\+]+://!i, @all);
- } elsif ($ok ne '') {
- return $lei->fail("--all=$all not understood");
- } else {
- @inc = @all;
- }
- for (@inc) {
- push(@folders, $_) unless $seen{$_}++;
- }
- }
- return $lei->fail(<<EOM) if !@folders;
-no --mail-sync folders known to lei
-EOM
+ if (defined(my $all = $opt->{all})) { # --all=<local|remote>
+ $lms->group2folders($lei, $all, \@folders) or return;
} else {
my $err = $lms->arg2folder($lei, \@folders);
$lei->qerr(@{$err->{qerr}}) if $err->{qerr};
diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm
index ec05404a..af47439a 100644
--- a/lib/PublicInbox/LeiMailSync.pm
+++ b/lib/PublicInbox/LeiMailSync.pm
@@ -315,6 +315,42 @@ sub match_imap_url {
"E: `$url' is ambiguous:\n\t".join("\n\t", @match)."\n";
}
+# returns undef on failure, number on success
+sub group2folders {
+ my ($self, $lei, $all, $folders) = @_;
+ return $lei->fail(<<EOM) if @$folders;
+--all= not compatible with @$folders on command-line
+EOM
+ my %x = map { $_ => $_ } split(/,/, $all);
+ my @ok = grep(defined, delete(@x{qw(local remote), ''}));
+ my @no = keys %x;
+ if (@no) {
+ @no = (join(',', @no));
+ return $lei->fail(<<EOM);
+--all=@no not accepted (must be `local' and/or `remote')
+EOM
+ }
+ my (%seen, @inc);
+ my @all = $self->folders;
+ for my $ok (@ok) {
+ if ($ok eq 'local') {
+ @inc = grep(!m!\A[a-z0-9\+]+://!i, @all);
+ } elsif ($ok eq 'remote') {
+ @inc = grep(m!\A[a-z0-9\+]+://!i, @all);
+ } elsif ($ok ne '') {
+ return $lei->fail("--all=$all not understood");
+ } else {
+ @inc = @all;
+ }
+ for (@inc) {
+ push(@$folders, $_) unless $seen{$_}++;
+ }
+ }
+ scalar(@$folders) || $lei->fail(<<EOM);
+no --mail-sync folders known to lei
+EOM
+}
+
# map CLI args to folder table entries, returns undef on failure
sub arg2folder {
my ($self, $lei, $folders) = @_;
^ permalink raw reply related [relevance 7%]
* [PATCH 0/5] lei Maildir stuff
@ 2021-06-09 7:47 6% Eric Wong
2021-06-09 7:47 7% ` [PATCH 4/5] lei_mail_sync: hoist out --all handling from export-kw Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-06-09 7:47 UTC (permalink / raw)
To: meta
I'm not sure if "prune-mail-sync" needs to be exposed, but I
suppose it could be useful in some cases. It's certainly easier
to implement.
"lei tag" gets a nice speedup for Maildirs, IMAP speedup is
probably better off done after we get IMAP pipelining far into
the future.
Not sure if anybody is using InboxWritable->import_maildir...
Eric Wong (5):
inbox_writable: fix import_maildir
mdir_reader: maildir_each_file: pass flags, skip Trash
lei tag: parallelize Maildir access
lei_mail_sync: hoist out --all handling from export-kw
lei prune-mail-sync: new command to prune invalid sync data
MANIFEST | 1 +
lib/PublicInbox/InboxWritable.pm | 15 ++---
lib/PublicInbox/LEI.pm | 2 +
lib/PublicInbox/LeiExportKw.pm | 32 +---------
lib/PublicInbox/LeiImport.pm | 12 ++--
lib/PublicInbox/LeiMailSync.pm | 36 +++++++++++
lib/PublicInbox/LeiPmdir.pm | 18 ++----
lib/PublicInbox/LeiPruneMailSync.pm | 97 +++++++++++++++++++++++++++++
lib/PublicInbox/LeiTag.pm | 8 ++-
lib/PublicInbox/MdirReader.pm | 5 +-
lib/PublicInbox/NetReader.pm | 19 ++++++
lib/PublicInbox/NetWriter.pm | 21 +------
12 files changed, 184 insertions(+), 82 deletions(-)
create mode 100644 lib/PublicInbox/LeiPruneMailSync.pm
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-06-09 7:47 6% [PATCH 0/5] lei Maildir stuff Eric Wong
2021-06-09 7:47 7% ` [PATCH 4/5] lei_mail_sync: hoist out --all handling from export-kw 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).