| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::CSE::Command::Check; |
|
2
|
|
|
|
|
|
|
$App::CSE::Command::Check::VERSION = '0.015'; |
|
3
|
1
|
|
|
1
|
|
558
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
|
|
extends qw/App::CSE::Command/; |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7123
|
use Lucy::Search::IndexSearcher; |
|
|
1
|
|
|
|
|
23686
|
|
|
|
1
|
|
|
|
|
30
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# To check for shared-mime-info DB. |
|
9
|
1
|
|
|
1
|
|
20
|
use File::BaseDir qw//; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Log::Log4perl; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
13
|
|
|
|
|
|
|
my $LOGGER = Log::Log4perl->get_logger(); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub execute{ |
|
16
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
27
|
my $index_dir = $self->cse()->index_dir(); |
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
5
|
unless( -d $index_dir ){ |
|
21
|
0
|
|
|
|
|
0
|
$LOGGER->warn("No index $index_dir. You should run 'cse index'"); |
|
22
|
0
|
|
|
|
|
0
|
return 1; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# The directory is there. Check it is a valid lucy index. |
|
26
|
1
|
|
|
|
|
51
|
my $lucy = eval{ my $l = Lucy::Search::IndexSearcher->new( index => $index_dir ); |
|
|
1
|
|
|
|
|
645
|
|
|
27
|
0
|
|
|
|
|
0
|
$l->get_reader(); |
|
28
|
0
|
|
|
|
|
0
|
$l->get_schema(); |
|
29
|
0
|
|
|
|
|
0
|
$l; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
1
|
50
|
|
|
|
881
|
unless( $lucy ){ |
|
32
|
1
|
|
|
|
|
2
|
my $err = $@; |
|
33
|
1
|
|
|
|
|
30
|
$LOGGER->error($self->cse->colorizer->colored("The index $index_dir is not a valid lucy index.", 'red bold')); |
|
34
|
1
|
|
|
|
|
406
|
$LOGGER->debug("Lucy error: $err"); |
|
35
|
1
|
|
|
|
|
298
|
return 1; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $dirty_str = ''; |
|
39
|
0
|
|
|
|
|
|
my $dirty_hash = $self->cse()->dirty_files(); |
|
40
|
0
|
0
|
|
|
|
|
if( my $ndirty = scalar( keys %$dirty_hash ) ){ |
|
41
|
0
|
|
|
|
|
|
$dirty_str = ' '.$ndirty.' dirty files - run cse update to clean them'; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$LOGGER->info("Index $index_dir is healthy.".$dirty_str); |
|
45
|
0
|
|
|
|
|
|
my $schema = $lucy->get_schema(); |
|
46
|
0
|
|
|
|
|
|
my @fields = sort @{ $schema->all_fields() }; |
|
|
0
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$LOGGER->info("Fields: ".join(', ', map{ $_.' ('._scrape_lucy_class($schema->fetch_type($_)).')' } @fields)); |
|
|
0
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$LOGGER->info($lucy->get_reader()->doc_count().' files indexed on '.$self->cse->index_mtime()->iso8601()); |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
unless( File::BaseDir::data_files('mime/globs') ){ |
|
51
|
0
|
|
|
|
|
|
$LOGGER->warn($self->cse->colorizer->colored(q|No mime type info database (mime-info) on the machine. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
All the files will be considered to be application/octet-stream at index time, making the search useless. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The shared-mime-info package is available from http://freedesktop.org/ |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
On linux: |
|
58
|
|
|
|
|
|
|
Check your package manager |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
On OSX: |
|
61
|
|
|
|
|
|
|
brew install shared-mime-info |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|, 'yellow bold')); |
|
64
|
0
|
|
|
|
|
|
return 1; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Check some watcher. |
|
68
|
0
|
0
|
|
|
|
|
if( my $watcher_pid = $self->cse->index_meta()->{'watcher.pid'} ){ |
|
69
|
0
|
|
|
|
|
|
$LOGGER->info("Dir watcher PID=".$watcher_pid); |
|
70
|
0
|
|
|
|
|
|
( $watcher_pid ) = ( $watcher_pid =~ /(\d+)/ ); |
|
71
|
0
|
0
|
|
|
|
|
if( kill(0 , $watcher_pid ) ){ |
|
72
|
0
|
|
|
|
|
|
$LOGGER->info("Watcher is Running"); |
|
73
|
|
|
|
|
|
|
}else{ |
|
74
|
0
|
|
|
|
|
|
$LOGGER->warn("Looks like watcher PID=$watcher_pid is defunct. Try cse unwatch to clean it up"); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return 0; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _scrape_lucy_class{ |
|
83
|
0
|
|
|
0
|
|
|
my ($o) = @_; |
|
84
|
0
|
|
|
|
|
|
my $ref = ref($o); |
|
85
|
0
|
|
|
|
|
|
$ref =~ s/Lucy::Plan:://; |
|
86
|
0
|
|
|
|
|
|
return $ref; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
App::CSE::Command::Check - Checks and display info about an index. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |