user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
6cfc80839f767bd9d5b7a838189b548cf284865c blob 2636 bytes (raw)

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
# Copyright (C) 2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

# "lei inspect" general purpose inspector for stuff in SQLite and
# Xapian.  Will eventually be useful with plain public-inboxes,
# not just lei/store.  This is totally half-baked at the moment
# but useful for testing.
package PublicInbox::LeiInspect;
use strict;
use v5.10.1;
use PublicInbox::Config;

sub inspect_blob ($$) {
	my ($lei, $oidhex) = @_;
	my $ent = {};
	if (my $lse = $lei->{lse}) {
		my @docids = $lse ? $lse->over->blob_exists($oidhex) : ();
		$ent->{'lei/store'} = \@docids if @docids;
		my $lms = $lse->lms;
		if (my $loc = $lms ? $lms->locations_for($oidhex) : undef) {
			$ent->{sync} = $loc;
		}
	}
	$ent;
}

sub inspect_sync_folder ($$) {
	my ($lei, $folder) = @_;
	my $ent = {};
	my $lse = $lei->{lse} or return $ent;
	my $lms = $lse->lms or return $ent;
	my @folders;
	if ($folder =~ m!\Aimaps?://!i) {
		require PublicInbox::URIimap;
		my $uri = PublicInbox::URIimap->new($folder)->canonical;
		if (defined($uri->uidvalidity)) {
			$folders[0] = $$uri;
		} else {
			my @maybe = $lms->folders($$uri);
			@folders = grep {
				my $u = PublicInbox::URIimap->new($_);
				$uri->uidvalidity($u->uidvalidity);
				$$uri eq $$u;
			} @maybe;
		}
	} elsif ($folder =~ m!\A(maildir|mh):(.+)!i) {
		my $type = $1;
		$folders[0] = "$type:".$lei->abs_path($2);
	} elsif (-d $folder) {
		$folders[0] = 'maildir:'.$lei->abs_path($folder);
	} else {
		$lei->fail("$folder not understood");
	}
	$lei->qerr("# no folders match $folder (non-fatal)") if !@folders;
	for my $f (@folders) {
		$ent->{$f} = $lms->location_stats($f); # may be undef
	}
	$ent
}

sub inspect1 ($$$) {
	my ($lei, $item, $more) = @_;
	my $ent;
	if ($item =~ /\Ablob:(.+)/) {
		$ent = inspect_blob($lei, $1);
	} elsif ($item =~ m!\Aimaps?://!i ||
			$item =~ m!\A(?:maildir|mh):!i || -d $item) {
		$ent = inspect_sync_folder($lei, $item);
	} else { # TODO: more things
		return $lei->fail("$item not understood");
	}
	$lei->out($lei->{json}->encode($ent));
	$lei->out(',') if $more;
	1;
}

sub lei_inspect {
	my ($lei, @argv) = @_;
	$lei->{1}->autoflush(0);
	my $multi = scalar(@argv) > 1;
	$lei->out('[') if $multi;
	$lei->{json} = ref(PublicInbox::Config::json())->new->utf8->canonical;
	$lei->{lse} = ($lei->{opt}->{external} // 1) ? do {
		my $sto = $lei->_lei_store;
		$sto ? $sto->search : undef;
	} : undef;
	if ($lei->{opt}->{pretty} || -t $lei->{1}) {
		$lei->{json}->pretty(1)->indent(2);
	}
	while (defined(my $x = shift @argv)) {
		inspect1($lei, $x, scalar(@argv)) or return;
	}
	$lei->out(']') if $multi;
}

1;
debug log:

solving 6cfc8083 ...
found 6cfc8083 in public-inbox.git

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git