public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob 053204fe932ac411806f0d490f8f96cef47bdb7c 1128 bytes (raw)
$ git show HEAD:xt/over-fsck.perl	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
#!perl -w
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# unstable dev script, chasing a bug which may be in LeiSavedSearch->is_dup
use v5.12;
use Data::Dumper;
use PublicInbox::OverIdx;
@ARGV == 1 or die "Usage: $0 /path/to/over.sqlite3\n";
my $over = PublicInbox::OverIdx->new($ARGV[0]);
my $dbh = $over->dbh;
$dbh->do('PRAGMA mmap_size = '.(2 ** 48));
my $num = 0;
my ($err, $none, $nr, $ids);
$Data::Dumper::Useqq = $Data::Dumper::Sortkeys = 1;
do {
	$ids = $over->ids_after(\$num);
	$nr += @$ids;
	for my $n (@$ids) {
		my $smsg = $over->get_art($n);
		if (!$smsg) {
			warn "#$n article missing\n";
			++$err;
			next;
		}
		my $exp = $smsg->{blob};
		if ($exp eq '') {
			++$none if $smsg->{bytes};
			next;
		}
		my $xr3 = $over->get_xref3($n, 1);
		my $found;
		for my $r (@$xr3) {
			$r->[2] = unpack('H*', $r->[2]);
			$found = 1 if $r->[2] eq $exp;
		}
		if (!$found) {
			warn Dumper([$smsg, $xr3 ]);
			++$err;
		}
	}
} while (@$ids);
warn "$none/$nr had no blob (external?)\n" if $none;
warn "$err errors\n" if $err;
exit($err ? 1 : 0);

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git