]> Sergey Matveev's repositories - public-inbox.git/commitdiff
compact: better handling of over.sqlite3* files
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 5 Apr 2018 09:34:12 +0000 (09:34 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 5 Apr 2018 10:27:13 +0000 (10:27 +0000)
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

index e69771650797b9a3ff55d1ca7f3755e7f2972799..b8aaa4bd812f7a54ffe7c8ef0af8d3878205b0c4 100755 (executable)
@@ -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"
                        }