File Coverage

blib/lib/Brackup/Target/Filebased.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 4 50.0
condition 4 5 80.0
subroutine 5 5 100.0
pod 0 2 0.0
total 32 37 86.4


line stmt bran cond sub pod time code
1             package Brackup::Target::Filebased;
2 5     5   44 use strict;
  5         11  
  5         394  
3 5     5   31 use warnings;
  5         11  
  5         395  
4 5     5   175 use base 'Brackup::Target';
  5         12  
  5         4331  
5              
6             # version >= 1.06: 01/23/0123456789abcdef...xxx.chunk
7             # 256 * 256 directories, then files. would need 2 billion
8             # files before leaves have 32k+ files, but at that point
9             # users are probably using better filesystems if they
10             # have 2+ billion inodes.
11             sub chunkpath {
12 273     273 0 1049 my ($self, $dig) = @_;
13 273         463 my @parts;
14 273         572 my $fulldig = $dig;
15              
16 273         4169 $dig =~ s/^\w+://; # remove the "hashtype:" from beginning
17 273 50       1801 $fulldig =~ s/:/./g if $self->nocolons; # Convert colons to dots if we've been asked to
18              
19 273   66     3110 while (length $dig && @parts < 2) {
20 546 50       18756 $dig =~ s/^([0-9a-f]{2})// or die "Can't get 2 hex digits of $fulldig";
21 546         5447 push @parts, $1;
22             }
23              
24 273         5014 return join("/", @parts) . "/$fulldig.chunk";
25             }
26              
27             sub metapath {
28 16     16 0 38 my ($self, $name) = @_;
29              
30 16   100     140 $name ||= '';
31              
32 16         82 return "backups/$name";
33             }
34              
35             1;