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 5B6FC1F9E5 for ; Sun, 23 May 2021 21:36:51 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] lei_mail_sync: reject IMAP URLs w/o UIDVALIDITY Date: Sun, 23 May 2021 21:36:51 +0000 Message-Id: <20210523213651.24941-3-e@80x24.org> In-Reply-To: <20210523213651.24941-1-e@80x24.org> References: <20210523213651.24941-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It's inappropriate to store sync information without UIDVALIDITY, so add an assertion to prevent it. --- lib/PublicInbox/LeiMailSync.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm index b2986686..63076fa1 100644 --- a/lib/PublicInbox/LeiMailSync.pm +++ b/lib/PublicInbox/LeiMailSync.pm @@ -7,6 +7,7 @@ use strict; use v5.10.1; use DBI; use PublicInbox::ContentHash qw(git_sha); +use Carp (); sub dbh_new { my ($self, $rw) = @_; @@ -88,6 +89,10 @@ UPDATE folders SET loc = ? WHERE fid = ? EOM return $fid; } + } elsif ($rw && $folder =~ m!\Aimaps?://!i) { + require PublicInbox::URIimap; + PublicInbox::URIimap->new($folder)->uidvalidity // + Carp::croak("BUG: $folder has no UIDVALIDITY"); } return unless $rw;