Skip to content

Commit

Permalink
reused cached repo data file to speed up building
Browse files Browse the repository at this point in the history
checksum and size is checked before trying to resuse it.
  • Loading branch information
xiaoqiang0 authored and mlschroe committed Sep 27, 2012
1 parent 3954961 commit 7891d30
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions createrepomddeps
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ my $repomdparser = {
repomd => {
data => {
_start => \&repomd_handle_data_start,
_end => \&repomd_handle_data_end,
location => {
_start => \&repomd_handle_location,
},
size => {
_text => \&repomd_handle_size,
},
},
},
};
Expand Down Expand Up @@ -72,6 +76,7 @@ my $primaryparser = {
# [ [tag, \%], ... ]
my @cursor = ();

my %datafile;
sub repomd_handle_data_start
{
my $p = shift;
Expand All @@ -83,16 +88,31 @@ sub repomd_handle_data_start
}
}

sub repomd_handle_data_end
{
my $p = shift;
my $el = shift;
push @primaryfiles, {%datafile};
}


sub repomd_handle_location
{
my $p = shift;
my $el = shift;

my $attr = map_attrs(@_);
if(exists $attr->{'href'}) {
push @primaryfiles, { location => $attr->{'href'} };
$datafile{location} = $attr->{'href'};
}
}
sub repomd_handle_size
{
my $p = shift;
my $el = shift;
$datafile{size} = $el;
}


sub generic_handle_start
{
Expand Down Expand Up @@ -421,7 +441,13 @@ for my $url (@ARGV) {
@cursor = ([undef, $primaryparser]);

my $u = $dir . $f->{'location'};
if ($url =~ /^http[s]?:\/\/([^\/]*)\/?/) {
my $size = 0;
my $cached = 0;
if ( -e $u ) {
$size = (stat($u))[7];
$cached = 1 if ($f->{'size'} == $size);
}
if ($url =~ /^http[s]?:\/\/([^\/]*)\/?/ and !$cached) {
if (system($INC[0].'/download', $dir . "repodata/", $baseurl . "repodata/" . basename($u))) {
die("download failed\n");
}
Expand Down

0 comments on commit 7891d30

Please sign in to comment.