]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mdir_reader: maildir_each_file: pass flags, skip Trash
authorEric Wong <e@80x24.org>
Wed, 9 Jun 2021 07:47:48 +0000 (07:47 +0000)
committerEric Wong <e@80x24.org>
Wed, 9 Jun 2021 10:03:43 +0000 (10:03 +0000)
This is a slight behavior change for "lei q": Trashed
(but not-yet-expunged) messages no longer get unlinked
when --output is used without --augment.

lib/PublicInbox/LeiImport.pm
lib/PublicInbox/LeiPmdir.pm
lib/PublicInbox/MdirReader.pm

index b0e7ba6bc490ef9d870e4c55f36a98a06e5b4597..cddd56192fad72700115579d3b1cfced28a33818 100644 (file)
@@ -30,11 +30,9 @@ sub input_mbox_cb { # MboxReader callback
 }
 
 sub pmdir_cb { # called via wq_io_do from LeiPmdir->each_mdir_fn
-       my ($self, $f, @args) = @_;
+       my ($self, $f, $fl) = @_;
        my ($folder, $bn) = ($f =~ m!\A(.+?)/(?:new|cur)/([^/]+)\z!) or
                die "BUG: $f was not from a Maildir?\n";
-       my $fl = PublicInbox::MdirReader::maildir_basename_flags($bn);
-       return if index($fl, 'T') >= 0; # no Trashed messages
        my $kw = PublicInbox::MdirReader::flags2kw($fl);
        substr($folder, 0, 0) = 'maildir:'; # add prefix
        my $lms = $self->{-lms_ro};
index b71efe701e76289c928e92f4f2828ab8f1934040..aa9ce713507a2448a1e50ced1ccd544669f8d756 100644 (file)
@@ -42,13 +42,13 @@ sub ipc_atfork_child {
 }
 
 sub each_mdir_fn { # maildir_each_file callback
-       my ($f, $self, @args) = @_;
-       $self->wq_io_do('mdir_iter', [], $f, @args);
+       my ($f, $fl, $self, @args) = @_;
+       $self->wq_io_do('mdir_iter', [], $f, $fl, @args);
 }
 
 sub mdir_iter { # via wq_io_do
-       my ($self, $f, @args) = @_;
-       $self->{ipt}->pmdir_cb($f, @args);
+       my ($self, $f, $fl, @args) = @_;
+       $self->{ipt}->pmdir_cb($f, $fl, @args);
 }
 
 sub pmd_done_wait {
index 484bf0a8dcee682afc3fded71cb9108cb098ee6d..dbb74d6d9772f85afb5b9b0fc4b4b07e1b61ac60 100644 (file)
@@ -42,9 +42,10 @@ sub maildir_each_file {
                my $pfx = $dir.$d;
                opendir my $dh, $pfx or next;
                while (defined(my $bn = readdir($dh))) {
-                       maildir_basename_flags($bn) // next;
+                       my $fl = maildir_basename_flags($bn) // next;
                        next if defined($mod) && !shard_ok($bn, $mod, $shard);
-                       $cb->($pfx.$bn, @arg);
+                       next if index($fl, 'T') >= 0; # no Trashed messages
+                       $cb->($pfx.$bn, $fl, @arg);
                }
        }
 }