]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mail_sync: set_src uses binary OIDs
authorEric Wong <e@80x24.org>
Tue, 31 Aug 2021 11:21:24 +0000 (11:21 +0000)
committerEric Wong <e@80x24.org>
Tue, 31 Aug 2021 11:29:12 +0000 (11:29 +0000)
Another step towards moving more of our internals to use binary
OIDs to avoid needless conversions before hitting disk.

lib/PublicInbox/LeiMailSync.pm
lib/PublicInbox/LeiStore.pm
t/lei_mail_sync.t

index 275e0cc4c433ce6b27fa43ee86984b5147885d6f..f8834a27720145e0d4f3a09bd47919a0d5cc96a2 100644 (file)
@@ -118,7 +118,7 @@ EOM
 }
 
 sub set_src {
-       my ($self, $oidhex, $folder, $id) = @_;
+       my ($self, $oidbin, $folder, $id) = @_;
        my $fid = $self->{fmap}->{$folder} //= fid_for($self, $folder, 1);
        my $sth;
        if (ref($id)) { # scalar name
@@ -131,7 +131,7 @@ INSERT OR IGNORE INTO blob2name (oidbin, fid, name) VALUES (?, ?, ?)
 INSERT OR IGNORE INTO blob2num (oidbin, fid, uid) VALUES (?, ?, ?)
 
        }
-       $sth->execute(pack('H*', $oidhex), $fid, $id);
+       $sth->execute($oidbin, $fid, $id);
 }
 
 sub clear_src {
index 28e36e89c7ca04c75da16e68ef34080bb3c8780e..5a48c064dc05e03651275e28165b3092d810ddd5 100644 (file)
@@ -229,7 +229,7 @@ sub lms_rename_folder {
 
 sub set_sync_info {
        my ($self, $oidhex, $folder, $id) = @_;
-       _lms_rw($self)->set_src($oidhex, $folder, $id);
+       _lms_rw($self)->set_src(pack('H*', $oidhex), $folder, $id);
 }
 
 sub _remove_if_local { # git->cat_async arg
index a5e5f5d30a0062b03cbe5b508914b889469a10a8..5daa49cd9e6c233e69a42caf8c4e10aea8c0aa55 100644 (file)
@@ -16,24 +16,25 @@ is_deeply([$ro->folders], [], 'no folders, yet');
 
 my $imap = 'imaps://bob@[::1]/INBOX;UIDVALIDITY=9';
 $lms->lms_begin;
-is($lms->set_src('deadbeef', $imap, 1), 1, 'set IMAP once');
-ok($lms->set_src('deadbeef', $imap, 1) == 0, 'set IMAP idempotently');
+my $deadbeef = "\xde\xad\xbe\xef";
+is($lms->set_src($deadbeef, $imap, 1), 1, 'set IMAP once');
+ok($lms->set_src($deadbeef, $imap, 1) == 0, 'set IMAP idempotently');
 $lms->lms_commit;
 is_deeply([$ro->folders], [$imap], 'IMAP folder added');
 is_deeply([$ro->folders($imap)], [$imap], 'IMAP folder with full GLOB');
 is_deeply([$ro->folders('imaps://bob@[::1]/INBOX')], [$imap],
                'IMAP folder with partial GLOB');
 
-is_deeply($ro->locations_for("\xde\xad\xbe\xef"),
+is_deeply($ro->locations_for($deadbeef),
        { $imap => [ 1 ] }, 'locations_for w/ imap');
 
 my $maildir = 'maildir:/home/user/md';
 my $fname = 'foo:2,S';
 $lms->lms_begin;
-ok($lms->set_src('deadbeef', $maildir, \$fname), 'set Maildir once');
-ok($lms->set_src('deadbeef', $maildir, \$fname) == 0, 'set Maildir again');
+ok($lms->set_src($deadbeef, $maildir, \$fname), 'set Maildir once');
+ok($lms->set_src($deadbeef, $maildir, \$fname) == 0, 'set Maildir again');
 $lms->lms_commit;
-is_deeply($ro->locations_for("\xde\xad\xbe\xef"),
+is_deeply($ro->locations_for($deadbeef),
        { $imap => [ 1 ], $maildir => [ $fname ] },
        'locations_for w/ maildir + imap');
 
@@ -45,7 +46,7 @@ if ('mess things up pretend old bug') {
        $lms->lms_commit;
 
        $lms->lms_begin;
-       ok($lms->set_src('deadbeef', $maildir, \$fname), 'set Maildir once');
+       ok($lms->set_src($deadbeef, $maildir, \$fname), 'set Maildir once');
        $lms->lms_commit;
 };