]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mail_sync: reject IMAP URLs w/o UIDVALIDITY
authorEric Wong <e@80x24.org>
Sun, 23 May 2021 21:36:51 +0000 (21:36 +0000)
committerEric Wong <e@80x24.org>
Mon, 24 May 2021 22:31:37 +0000 (22:31 +0000)
It's inappropriate to store sync information without
UIDVALIDITY, so add an assertion to prevent it.

lib/PublicInbox/LeiMailSync.pm

index b298668658b650a7d269f96896e062e4e8ba835a..63076fa1c0712c45b82f44e5446ff05b8b1fe31c 100644 (file)
@@ -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;