line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ukigumo::Agent::Cleaner; |
2
|
5
|
|
|
5
|
|
25
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
117
|
|
3
|
5
|
|
|
5
|
|
1105
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
115
|
|
4
|
5
|
|
|
5
|
|
22
|
use utf8; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
24
|
|
5
|
5
|
|
|
5
|
|
113
|
use parent "Exporter"; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
38
|
|
6
|
5
|
|
|
5
|
|
279
|
use File::Path qw/rmtree/; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1158
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/cleanup_old_branch_dir/; |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
|
sub ONE_DAY { 60 * 60 * 24 } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub cleanup_old_branch_dir { |
13
|
0
|
|
|
0
|
0
|
|
my ($parent_dir, $cleanup_cycle) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
return if $cleanup_cycle <= 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
|
0
|
|
|
|
|
if ($now - $last_modified > $cleanup_cycle * ONE_DAY()) { |
21
|
0
|
|
|
|
|
|
rmtree($branches_dir); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|