| 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
| |||||||||||
| 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
| |||||||||||
| 21 | 0 | rmtree($branches_dir); | |||||||||
| 22 | } | ||||||||||
| 23 | } | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 7 | 1; | |||||||||
| 27 | |||||||||||