From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH] v2writable: use {inboxdir} for msgmap->tmp_clone
Date: Tue, 28 Jul 2020 23:25:54 +0000 [thread overview]
Message-ID: <20200728232554.1762-1-e@yhbt.net> (raw)
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 | 4 ++--
lib/PublicInbox/V2Writable.pm | 2 +-
t/msgmap.t | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index 839ddf7c..51b6a68c 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -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);
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 6908bd2e..6b0bdc73 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -1225,7 +1225,7 @@ 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->{inboxdir});
}
if ($sync->{index_max_size} = $self->{ibx}->{index_max_size}) {
$sync->{index_oid} = \&index_oid;
diff --git a/t/msgmap.t b/t/msgmap.t
index 1d7d1e87..437e106e 100644
--- a/t/msgmap.t
+++ b/t/msgmap.t
@@ -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');
next reply other threads:[~2020-07-28 23:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 23:25 Eric Wong [this message]
2020-07-29 11:32 ` [PATCH] v2writable: use {inboxdir} for msgmap->tmp_clone Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200728232554.1762-1-e@yhbt.net \
--to=e@yhbt.net \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).