]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: use {inboxdir} for msgmap->tmp_clone
authorEric Wong <e@yhbt.net>
Tue, 28 Jul 2020 22:11:32 +0000 (22:11 +0000)
committerEric Wong <e@yhbt.net>
Wed, 29 Jul 2020 11:32:50 +0000 (11:32 +0000)
Otherwise, a user is more likely to remove the msgmap-XXXXXXXX
SQLite file from $TMPDIR and cause SQLite to error out.

lib/PublicInbox/Msgmap.pm
lib/PublicInbox/V2Writable.pm
t/msgmap.t

index 839ddf7cadbbec6b85dde59de1334b55b5a721c7..51b6a68c8547e81a4eaf9168000354fea548085a 100644 (file)
@@ -48,8 +48,8 @@ sub new_file {
 
 # used to keep track of used numeric mappings for v2 reindex
 sub tmp_clone {
-       my ($self) = @_;
-       my ($fh, $fn) = tempfile('msgmap-XXXXXXXX', EXLOCK => 0, TMPDIR => 1);
+       my ($self, $dir) = @_;
+       my ($fh, $fn) = tempfile('msgmap-XXXXXXXX', EXLOCK => 0, DIR => $dir);
        my $tmp;
        if ($self->{dbh}->can('sqlite_backup_to_dbh')) {
                $tmp = ref($self)->new_file($fn, 2);
index 6908bd2eea80dc9317031ad83b8d264658c2894f..e071bc1e02109d6181c44598747a192c9fea7f3f 100644 (file)
@@ -1225,7 +1225,8 @@ sub index_sync {
                # only for batch performance.
                $self->{mm}->{dbh}->rollback;
                $self->{mm}->{dbh}->begin_work;
-               $sync->{mm_tmp} = $self->{mm}->tmp_clone;
+               $sync->{mm_tmp} =
+                       $self->{mm}->tmp_clone($self->{ibx}->{inboxdir});
        }
        if ($sync->{index_max_size} = $self->{ibx}->{index_max_size}) {
                $sync->{index_oid} = \&index_oid;
index 1d7d1e87adbb7bbe3316c9ad86bcbddc920ec24f..437e106e3dcd842d4e02866166a9941cdaef061e 100644 (file)
@@ -60,7 +60,7 @@ my $orig = $d->mid_insert('spam@1');
 $d->mid_delete('spam@1');
 is($d->mid_insert('spam@2'), 1 + $orig, "last number not recycled");
 
-my $tmp = $d->tmp_clone;
+my $tmp = $d->tmp_clone($tmpdir);
 is_deeply([$d->minmax], [$tmp->minmax], 'Cloned temporary DB matches');
 ok($tmp->mid_delete('spam@2'), 'temporary DB is writable');