Cmd/Command/FSCK.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl
2  
3 package KiokuDB::Cmd::Command::FSCK;
4 use Moose;
5  
6 use namespace::clean -except => 'meta';
7  
8 extends qw(KiokuDB::Cmd::Base);
9  
10 with qw(
11 KiokuDB::Cmd::WithDSN::Read
12 KiokuDB::Cmd::SpecifiedEntries
13 );
14  
15 has '+verbose' => ( default => 1 );
16  
17 has print => (
18 traits => [qw(Getopt)],
19 isa => "Bool",
20 is => "ro",
21 default => 1,
22 cmd_aliases => "p",
23 documentation => "print broken entries to STDOUT at end",
24 );
25  
26 augment run => sub {
27 my $self = shift;
28  
29 require KiokuDB::LinkChecker;
30  
31 my $l = KiokuDB::LinkChecker->new(
32 backend => $self->backend,
33 entries => $self->entries,
34 verbose => $self->verbose,
35 );
36  
37 if ( $l->missing->size == 0 ) {
38 $self->v("no missing entries, everything is OK\n");
39  
40 if ( $l->root->size ) {
41 my $purge = $l->unreferenced->difference($l->root);
42  
43 if ( my $count = $purge->size ) {
44 $self->v( "found $count unreferenced, non root objects\n" );
45 }
46 } else {
47 $self->v("WARNING: no root entries found\n");
48 }
49 } else {
50 if ( $self->print ) {
51 local $, = local $\ = "\n";
52 print STDOUT $l->broken->members;
53 }
54 $self->exit_code(1);
55 }
56 };
57  
58 __PACKAGE__->meta->make_immutable;
59  
60 __PACKAGE__
61  
62 __END__