unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Cc: meta@public-inbox.org
Subject: Re: [PATCH] uri_imap: fix ->uidvalidity and ->uid w/ `/' separator
Date: Wed, 15 Sep 2021 17:43:41 +0000	[thread overview]
Message-ID: <20210915174341.GA23047@dcvr> (raw)
In-Reply-To: <20210915123347.knr4qpaei73tjc5q@meerkat.local>

Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> On Tue, Sep 14, 2021 at 10:10:36PM +0000, Eric Wong wrote:
> > Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> > > 	2021-09-14T20:59:12Z 20428 20428 die: BUG: imaps://imap.migadu.com/lore/b4;UIDVALIDITY=1621977334 has no UIDVALIDITY at /usr/local/share/perl/5.32.1/PublicInbox/LeiStore.pm line 313.
> > > 	 (from nowait set_sync_info)
> > 
> > Same bug, different place :x
> > --------8<------
> > Subject: [PATCH] uri_imap: fix ->uidvalidity and ->uid w/ `/' separator
> > 
> > Again, we were failing to account for '/' use in mailbox names :x
> 
> The error is gone, but the saved search still doesn't show up when I run
> "lei ls-search". Looking in .local/share/lei/saved-searches, I see that they
> still get created as lore/foldername-${checksum}, which is probably why
> ls-search doesn't find them?

Ah, it's because the "foldername" part was incorrectly parsed
and it should be .local/share/lei/saved-searches/foldername-$checksum
without the "lore/" parent.

Once patched with the below, you should be able to move the
folder up a level and remove the now-empty "lore" dir inside
saved-searches.

Anyways, I think this fixes it:
---------8<---------
Subject: [PATCH] lei_saved_search: fix prefix for IMAP folders w/ slash

We failed to account for IMAP mailboxes containing `/'
characters when creating saved search files for them.

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210915123347.knr4qpaei73tjc5q@meerkat.local/
---
 lib/PublicInbox/LeiSavedSearch.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm
index 8ceaaf01..96ff816e 100644
--- a/lib/PublicInbox/LeiSavedSearch.pm
+++ b/lib/PublicInbox/LeiSavedSearch.pm
@@ -39,21 +39,21 @@ sub cfg_dump ($$) {
 
 sub lss_dir_for ($$;$) {
 	my ($lei, $dstref, $on_fs) = @_;
-	my @n;
+	my $pfx;
 	if ($$dstref =~ m,\Aimaps?://,i) { # already canonicalized
 		require PublicInbox::URIimap;
 		my $uri = PublicInbox::URIimap->new($$dstref)->canonical;
 		$$dstref = $$uri;
-		@n = ($uri->mailbox);
+		$pfx = $uri->mailbox;
 	} else {
 		# can't use Cwd::abs_path since dirname($$dstref) may not exist
 		$$dstref = $lei->rel2abs($$dstref);
 		$$dstref =~ tr!/!/!s;
-		@n = ($$dstref =~ m{([^/]+)/*\z}); # basename
+		$pfx = $$dstref;
 	}
-	push @n, sha256_hex($$dstref);
+	($pfx) = ($pfx =~ m{([^/]+)/*\z}); # basename
 	my $lss_dir = $lei->share_path . '/saved-searches/';
-	my $d = $lss_dir . join('-', @n);
+	my $d = "$lss_dir$pfx-".sha256_hex($$dstref);
 
 	# fall-back to looking up by st_ino + st_dev in case we're in
 	# a symlinked or bind-mounted path
@@ -61,7 +61,7 @@ sub lss_dir_for ($$;$) {
 		my @cur = stat(_);
 		my $want = pack('dd', @cur[1,0]); # st_ino + st_dev
 		my ($c, $o, @st);
-		for my $g ("$n[0]-*", '*') {
+		for my $g ("$pfx-*", '*') {
 			my @maybe = glob("$lss_dir$g/lei.saved-search");
 			for my $f (@maybe) {
 				$c = cfg_dump($lei, $f) // next;

  reply	other threads:[~2021-09-15 17:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 17:50 Wrong folder when using imaps:// Konstantin Ryabitsev
2021-09-14 19:35 ` [PATCH] uri_imap: handle '/' as an IMAP hierarchy separator Eric Wong
2021-09-14 19:55   ` Konstantin Ryabitsev
2021-09-14 20:12     ` Eric Wong
2021-09-14 20:19       ` Konstantin Ryabitsev
2021-09-14 21:05     ` Konstantin Ryabitsev
2021-09-14 22:10       ` [PATCH] uri_imap: fix ->uidvalidity and ->uid w/ `/' separator Eric Wong
2021-09-15 12:33         ` Konstantin Ryabitsev
2021-09-15 17:43           ` Eric Wong [this message]
2021-09-15 17:57             ` Konstantin Ryabitsev

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=20210915174341.GA23047@dcvr \
    --to=e@80x24.org \
    --cc=konstantin@linuxfoundation.org \
    --cc=meta@public-inbox.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).