From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 636081F8C6; Wed, 15 Sep 2021 17:43:41 +0000 (UTC) Date: Wed, 15 Sep 2021 17:43:41 +0000 From: Eric Wong To: Konstantin Ryabitsev Cc: meta@public-inbox.org Subject: Re: [PATCH] uri_imap: fix ->uidvalidity and ->uid w/ `/' separator Message-ID: <20210915174341.GA23047@dcvr> References: <20210914175025.eq7s2shkc323itaf@meerkat.local> <20210914193528.29676-1-e@80x24.org> <20210914195510.kozlchcwvgrng5uc@meerkat.local> <20210914210547.akdp4cqmwaheayp5@meerkat.local> <20210914221036.GA4907@dcvr> <20210915123347.knr4qpaei73tjc5q@meerkat.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210915123347.knr4qpaei73tjc5q@meerkat.local> List-Id: Konstantin Ryabitsev wrote: > On Tue, Sep 14, 2021 at 10:10:36PM +0000, Eric Wong wrote: > > Konstantin Ryabitsev 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 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;