Skip to content

Commit

Permalink
Use HTTP::Cache::Transparent if available
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Nov 12, 2019
1 parent bef3aca commit 10db0c1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ my %urls = (

foreach my $url(keys %urls) {
next if(-r $urls{$url});
if(eval { require HTTP::Cache::Transparent; }) {
HTTP::Cache::Transparent->import();
my $cachedir;
if(my $e = $ENV{'CACHEDIR'}) {
$cachedir = File::Spec->catfile($e, 'http-cache-transparent');
} else {
$cachedir = File::Spec->catfile(File::Spec->tmpdir(), 'cache', 'http-cache-transparent');
}

HTTP::Cache::Transparent::init({
BasePath => $cachedir,
# Verbose => $opts{'v'} ? 1 : 0,
NoUpdate => 60 * 60 * 24,
MaxAge => 30 * 24
}) || die "$0: $cachedir: $!";
}

print "Downloading $url\n";
my $ff = File::Fetch->new(uri => $url);
if(my $path = $ff->fetch($url)) {
Expand Down

0 comments on commit 10db0c1

Please sign in to comment.