blib/lib/Ukigumo/Agent/Cleaner.pm

filter: Statementstmt 68.0% 17 / 25 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 57.8% 22 / 38 SCAR 16.4
CC
4
Cov
59%
cleanup_old_branch_dir
20.0
ONE_DAY
2.0
BEGIN
1.0
CRAP 5.1
« blib/lib/Ukigumo/Agent.pm ↑ Summary blib/lib/Ukigumo/Agent/View.pm »
1 package Ukigumo::Agent::Cleaner;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use parent "Exporter";
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use File::Path qw/rmtree/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 our @EXPORT_OK = qw/cleanup_old_branch_dir/;
9  
10 0 ▶sub ONE_DAY { 60 * 60 * 24 }
Subroutine ONE_DAY: not called CC=1 SCAR=6.9
Pod undocumented
11  
12 sub cleanup_old_branch_dir {
13 0 ▶ my ($parent_dir, $cleanup_cycle) = @_;
Subroutine cleanup_old_branch_dir: not called CC=4 SCAR=30.0
Pod undocumented
14  
15 0 ▶ return if $cleanup_cycle <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $cleanup_cycle <= 0 0 0 0
16  
17 0 my $now = time;
18 0 for my $branches_dir (glob "$parent_dir/*") {
19 0 my $last_modified = (stat $branches_dir)[9];
20 0 ▶ if ($now - $last_modified > $cleanup_cycle * ONE_DAY()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($now - $last_modified > $cleanup_cycle * ONE_DAY()) 0 0 0
21 0 rmtree($branches_dir);
22 }
23 }
24 }
25  
26 7 1;
27  
« blib/lib/Ukigumo/Agent.pm ↑ Summary blib/lib/Ukigumo/Agent/View.pm »