From 5038857ec7663674c782affa11d5f33620107555 Mon Sep 17 00:00:00 2001 From: "Eric Wong (Contractor, The Linux Foundation)" Date: Thu, 5 Apr 2018 09:34:12 +0000 Subject: compact: better handling of over.sqlite3* files Lets not scare users when they encounter files that are supposed to be there. Then, preserve the journal and pipe.lock, even if they're supposedly unused due to us holding the inbox-wide lock. --- script/public-inbox-compact | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'script') diff --git a/script/public-inbox-compact b/script/public-inbox-compact index e6977165..b8aaa4bd 100755 --- a/script/public-inbox-compact +++ b/script/public-inbox-compact @@ -35,8 +35,16 @@ $ibx->umask_prepare; sub commit_changes ($$$) { my ($im, $old, $new) = @_; my @st = stat($old) or die "failed to stat($old): $!\n"; + + for my $suf (qw(.pipe.lock -journal)) { + my $orig = "$old/over.sqlite3$suf"; + link($orig, "$new/over.sqlite3$suf") and next; + next if $!{ENOENT}; + die "failed to link $orig => $new/over.sqlite3$suf: $!\n"; + } link("$old/over.sqlite3", "$new/over.sqlite3") or die "failed to link {$old => $new}/over.sqlite3: $!\n"; + rename($old, "$new/old") or die "rename $old => $new/old: $!\n"; chmod($st[2] & 07777, $new) or die "chmod $old: $!\n"; rename($new, $old) or die "rename $new => $old: $!\n"; @@ -58,6 +66,7 @@ if ($v == 2) { if ($dn =~ /\A\d+\z/) { push @parts, "$old/$dn"; } elsif ($dn eq '.' || $dn eq '..') { + } elsif ($dn =~ /\Aover\.sqlite3/) { } else { warn "W: skipping unknown Xapian DB: $old/$dn\n" } -- cgit v1.2.3-24-ge0c7