Favor oidbin use internally to reduce internal memory traffic.
my ($lei, $oidhex) = @_;
my $ent = {};
if (my $lse = $lei->{lse}) {
- my @docids = $lse ? $lse->over->blob_exists($oidhex) : ();
+ my $oidbin = pack('H*', $oidhex);
+ my @docids = $lse ? $lse->over->oidbin_exists($oidbin) : ();
$ent->{'lei/store'} = \@docids if @docids;
my $lms = $lse->lms;
- if (my $loc = $lms ? $lms->locations_for($oidhex) : undef) {
+ if (my $loc = $lms ? $lms->locations_for($oidbin) : undef) {
$ent->{'mail-sync'} = $loc;
}
}
# returns a { location => [ list-of-ids-or-names ] } mapping
sub locations_for {
- my ($self, $oidhex) = @_;
+ my ($self, $oidbin) = @_;
my ($fid, $sth, $id, %fid2id);
my $dbh = $self->{dbh} //= dbh_new($self);
$sth = $dbh->prepare('SELECT fid,uid FROM blob2num WHERE oidbin = ?');
- $sth->execute(pack('H*', $oidhex));
+ $sth->execute($oidbin);
while (my ($fid, $uid) = $sth->fetchrow_array) {
push @{$fid2id{$fid}}, $uid;
}
$sth = $dbh->prepare('SELECT fid,name FROM blob2name WHERE oidbin = ?');
- $sth->execute(pack('H*', $oidhex));
+ $sth->execute($oidbin);
while (my ($fid, $name) = $sth->fetchrow_array) {
push @{$fid2id{$fid}}, $name;
}
$sth->execute($fid);
my ($loc) = $sth->fetchrow_array;
unless (defined $loc) {
+ my $oidhex = unpack('H*', $oidbin);
warn "E: fid=$fid for $oidhex unknown:\n", map {
'E: '.(ref() ? $$_ : "#$_")."\n";
} @$ids;
is_deeply([$ro->folders('imaps://bob@[::1]/INBOX')], [$imap],
'IMAP folder with partial GLOB');
-is_deeply($ro->locations_for('deadbeef'),
+is_deeply($ro->locations_for("\xde\xad\xbe\xef"),
{ $imap => [ 1 ] }, 'locations_for w/ imap');
my $maildir = 'maildir:/home/user/md';
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('deadbeef'),
+is_deeply($ro->locations_for("\xde\xad\xbe\xef"),
{ $imap => [ 1 ], $maildir => [ $fname ] },
'locations_for w/ maildir + imap');