| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::QuickDB::Util; |
|
2
|
10
|
|
|
10
|
|
59
|
use strict; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
243
|
|
|
3
|
10
|
|
|
10
|
|
47
|
use warnings; |
|
|
10
|
|
|
|
|
16
|
|
|
|
10
|
|
|
|
|
347
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000022'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
52
|
use IPC::Cmd qw/can_run/; |
|
|
10
|
|
|
|
|
27
|
|
|
|
10
|
|
|
|
|
343
|
|
|
8
|
10
|
|
|
10
|
|
47
|
use Carp qw/confess/; |
|
|
10
|
|
|
|
|
46
|
|
|
|
10
|
|
|
|
|
464
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
10
|
|
|
10
|
|
87
|
use Importer Importer => 'import'; |
|
|
10
|
|
|
|
|
35
|
|
|
|
10
|
|
|
|
|
79
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw/clone_dir strip_hash_defaults/; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my ($RSYNC, $CP); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
BEGIN { |
|
17
|
10
|
|
|
10
|
|
722
|
local $@; |
|
18
|
10
|
|
|
|
|
34
|
$RSYNC = can_run('rsync'); |
|
19
|
10
|
|
|
|
|
782232
|
$CP = can_run('cp'); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub clone_dir { |
|
23
|
0
|
0
|
|
0
|
0
|
|
return _clone_dir_rsync(@_) if $RSYNC; |
|
24
|
0
|
0
|
|
|
|
|
return _clone_dir_cp(@_) if $CP; |
|
25
|
0
|
|
|
|
|
|
return _clone_dir_fcr(@_); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _clone_dir_rsync { |
|
29
|
0
|
|
|
0
|
|
|
my ($src, $dest, %params) = @_; |
|
30
|
0
|
0
|
|
|
|
|
system($RSYNC, '-a', '--exclude' => '.nfs*', $params{verbose} ? ( '-vP' ) : (), "$src/", $dest) and die "$RSYNC returned $?"; |
|
|
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _clone_dir_cp { |
|
34
|
0
|
|
|
0
|
|
|
my ($src, $dest, %params) = @_; |
|
35
|
0
|
0
|
|
|
|
|
system($CP, '-a', $params{verbose} ? ( '-v' ) : (), "$src/", $dest) and die "$CP returned $?"; |
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _clone_dir_fcr { |
|
39
|
0
|
|
|
0
|
|
|
my ($src, $dest, %params) = @_; |
|
40
|
0
|
|
|
|
|
|
require File::Copy::Recursive; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
File::Copy::Recursive::dircopy($src, $dest) or die "$!"; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub strip_hash_defaults { |
|
46
|
0
|
|
|
0
|
0
|
|
my ($hash, $defaults) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $out = {%$hash}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
for my $key (keys %$defaults) { |
|
51
|
0
|
|
|
|
|
|
my $refout = ref($out->{$key}); |
|
52
|
0
|
|
|
|
|
|
my $refdef = ref($defaults->{$key}); |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
|
if ($refout eq $refdef && $refdef eq 'HASH') { |
|
55
|
0
|
|
|
|
|
|
$out->{$key} = strip_hash_defaults($out->{$key}, $defaults->{$key}); |
|
56
|
0
|
|
|
|
|
|
next; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ($refout ne $refdef) { |
|
60
|
0
|
|
|
|
|
|
delete $out->{$key}; |
|
61
|
0
|
|
|
|
|
|
next; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
10
|
|
|
10
|
|
5483
|
no warnings 'numeric'; |
|
|
10
|
|
|
|
|
25
|
|
|
|
10
|
|
|
|
|
1051
|
|
|
65
|
0
|
0
|
0
|
|
|
|
delete $out->{$key} if $out->{$key} && $out->{$key} eq $defaults->{$key}; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $out; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |