]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imaptracker: update_last: simplify callers
authorEric Wong <e@yhbt.net>
Fri, 28 Aug 2020 10:12:59 +0000 (10:12 +0000)
committerEric Wong <e@yhbt.net>
Fri, 28 Aug 2020 22:19:27 +0000 (22:19 +0000)
By making it a no-op if last_uid is not defined.  This isn't a
hot code path, so the extra method dispatch isn't an issue.
It'll save some indentation/wrapping in future commits.

lib/PublicInbox/IMAPTracker.pm
lib/PublicInbox/WatchMaildir.pm

index 92f21584842d97d2d6d1d3747596e251ad8719d6..be9caf7648bf3f59ede7caff161f813ed2372022 100644 (file)
@@ -49,13 +49,14 @@ SELECT uid_validity, uid FROM imap_last WHERE url = ?
 }
 
 sub update_last ($$$) {
-       my ($self, $validity, $last) = @_;
+       my ($self, $validity, $last_uid) = @_;
+       return unless defined $last_uid;
        my $sth = $self->{dbh}->prepare_cached(<<'');
 INSERT OR REPLACE INTO imap_last (url, uid_validity, uid)
 VALUES (?, ?, ?)
 
        $self->lock_acquire;
-       my $rv = $sth->execute($self->{url}, $validity, $last);
+       my $rv = $sth->execute($self->{url}, $validity, $last_uid);
        $self->lock_release;
        $rv;
 }
index 78aec8a25d5f4b6cfd3103917ecc93aed6ba2a7b..a227a6fd2719746e77070432285db893d5c890c7 100644 (file)
@@ -494,7 +494,7 @@ sub imap_fetch_all ($$$) {
                        last if $self->{quit};
                }
                _done_for_now($self);
-               $itrk->update_last($r_uidval, $last_uid) if defined $last_uid;
+               $itrk->update_last($r_uidval, $last_uid);
        } until ($err || $self->{quit});
        $err;
 }
@@ -919,7 +919,7 @@ sub nntp_fetch_all ($$$) {
                $last_art = $art;
        }
        _done_for_now($self);
-       $itrk->update_last(0, $last_art) if defined $last_art;
+       $itrk->update_last(0, $last_art);
        $err;
 }