repomd => {
data => {
_start => \&repomd_handle_data_start,
+ _end => \&repomd_handle_data_end,
location => {
_start => \&repomd_handle_location,
},
+ size => {
+ _text => \&repomd_handle_size,
+ },
},
},
};
# [ [tag, \%], ... ]
my @cursor = ();
+my %datafile;
sub repomd_handle_data_start
{
my $p = shift;
}
}
+sub repomd_handle_data_end
+{
+ my $p = shift;
+ my $el = shift;
+ push @primaryfiles, {%datafile};
+}
+
+
sub repomd_handle_location
{
my $p = 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
{
@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");
}