Alien-Build-Plugin-Fetch-Cache
view release on metacpan or search on metacpan
bin/abcache view on Meta::CPAN
say "RM $_[0]";
unlink $_[0];
};
my $rmdir = sub {
say "RMDIR $_[0]";
rmdir $_[0];
};
recurse(sub {
my($uri, $meta, $metafile) = @_;
my $dir = $metafile->parent;
if($meta->{path})
{
$rm->($meta->{path});
}
$rm->($metafile);
$rmdir->($dir);
lib/Alien/Build/Plugin/Fetch/Cache.pm view on Meta::CPAN
if(-r $local_file)
{
$build->log("using cached response for $uri");
return decode_sereal($local_file->slurp_raw);
}
}
my $res = $orig->($build, $url);
if(defined $local_file)
{
$local_file->parent->mkpath;
if($res->{type} eq 'file')
{
my $md5 = Digest::MD5->new;
if($res->{content})
{
$md5->add($res->{content});
}
else
{
open my $fh, '<', $res->{path};
$md5->addfile($fh);
close $fh;
}
my $data = Path::Tiny->new(bsd_glob '~/.alienbuild/plugin_fetch_cache/payload')
->child($md5->hexdigest)
->child($res->{filename});
$data->parent->mkpath;
my $res2 = {
type => 'file',
filename => $res->{filename},
path => $data->stringify,
protocol => $res->{protocol},
};
if($res->{content})
{
$data->spew_raw($res->{content});
( run in 0.262 second using v1.01-cache-2.11-cpan-4d50c553e7e )