unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/5] mdir_reader: maildir_each_file: pass flags, skip Trash
Date: Wed,  9 Jun 2021 07:47:48 +0000	[thread overview]
Message-ID: <20210609074751.29217-3-e@80x24.org> (raw)
In-Reply-To: <20210609074751.29217-1-e@80x24.org>

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  | 4 +---
 lib/PublicInbox/LeiPmdir.pm   | 8 ++++----
 lib/PublicInbox/MdirReader.pm | 5 +++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm
index b0e7ba6b..cddd5619 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -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};
diff --git a/lib/PublicInbox/LeiPmdir.pm b/lib/PublicInbox/LeiPmdir.pm
index b71efe70..aa9ce713 100644
--- a/lib/PublicInbox/LeiPmdir.pm
+++ b/lib/PublicInbox/LeiPmdir.pm
@@ -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 {
diff --git a/lib/PublicInbox/MdirReader.pm b/lib/PublicInbox/MdirReader.pm
index 484bf0a8..dbb74d6d 100644
--- a/lib/PublicInbox/MdirReader.pm
+++ b/lib/PublicInbox/MdirReader.pm
@@ -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);
 		}
 	}
 }

  parent reply	other threads:[~2021-06-09  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  7:47 [PATCH 0/5] lei Maildir stuff Eric Wong
2021-06-09  7:47 ` [PATCH 1/5] inbox_writable: fix import_maildir Eric Wong
2021-06-09  7:47 ` Eric Wong [this message]
2021-06-09  7:47 ` [PATCH 3/5] lei tag: parallelize Maildir access Eric Wong
2021-06-09  7:47 ` [PATCH 4/5] lei_mail_sync: hoist out --all handling from export-kw Eric Wong
2021-06-09  7:47 ` [PATCH 5/5] lei prune-mail-sync: new command to prune invalid sync data Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210609074751.29217-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --subject='Re: [PATCH 2/5] mdir_reader: maildir_each_file: pass flags, skip Trash' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

unofficial mirror of meta@public-inbox.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://yhetil.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.public-inbox.meta
	nntp://news.public-inbox.org/inbox.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git