]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiMailSync.pm
lei import: import IMAP flag changes from old messages
[public-inbox.git] / lib / PublicInbox / LeiMailSync.pm
index c7f78239e7e50c5101ed943d7be3b2f316eb8782..36cd564cd7477467b75e1f28ff6428c10af3b499 100644 (file)
@@ -361,6 +361,17 @@ sub forget_folder {
        $dbh->do('DELETE FROM folders WHERE fid = ?', undef, $fid);
 }
 
+sub imap_oid2 ($$$) {
+       my ($self, $uri, $uid) = @_; # $uri MUST have UIDVALIDITY
+       my $fid = $self->{fmap}->{"$uri"} //= fid_for($self, "$uri") // return;
+       my $sth = $self->{dbh}->prepare_cached(<<EOM, undef, 1);
+SELECT oidbin FROM blob2num WHERE fid = ? AND uid = ?
+EOM
+       $sth->execute($fid, $uid);
+       my ($oidbin) = $sth->fetchrow_array;
+       $oidbin ? unpack('H*', $oidbin) : undef;
+}
+
 sub imap_oid {
        my ($self, $lei, $uid_uri) = @_;
        my $mailbox_uri = $uid_uri->clone;
@@ -373,16 +384,10 @@ sub imap_oid {
                }
                $lei->qerr(@{$err->{qerr}}) if $err->{qerr};
        }
-       my $fid = $self->{fmap}->{$folders->[0]} //=
-               fid_for($self, $folders->[0]) // return;
-       my $sth = $self->{dbh}->prepare_cached(<<EOM, undef, 1);
-SELECT oidbin FROM blob2num WHERE fid = ? AND uid = ?
-EOM
-       $sth->execute($fid, $uid_uri->uid);
-       my ($oidbin) = $sth->fetchrow_array;
-       $oidbin ? unpack('H*', $oidbin) : undef;
+       imap_oid2($self, $folders->[0], $uid_uri->uid);
 }
 
+
 # FIXME: something with "lei <up|q>" is causing uncommitted transaction
 # warnings, not sure what...
 sub DESTROY {