my $el = shift;
my $attr = map_attrs(@_);
+ %datafile = ();
if($attr->{'type'} ne 'primary') {
pop @cursor;
}
{
my $p = shift;
my $el = shift;
- push @primaryfiles, {%datafile};
+ push @primaryfiles, { %datafile } if exists $datafile{'location'};
}
my $el = shift;
my $attr = map_attrs(@_);
- if(exists $attr->{'href'}) {
- $datafile{location} = $attr->{'href'};
- }
+ $datafile{'location'} = $attr->{'href'} if defined $attr->{'href'};
}
+
sub repomd_handle_size
{
my $p = shift;
my $el = shift;
- $datafile{size} = $el;
+ $datafile{'size'} = $el;
}
@cursor = ([undef, $primaryparser]);
my $u = $dir . $f->{'location'};
- my $size = 0;
- my $cached = 0;
- if ( -e $u ) {
- $size = (stat($u))[7];
- $cached = 1 if ($f->{'size'} == $size);
+ if ($] > 5.007) {
+ require Encode;
+ utf8::downgrade($u);
+ }
+ my $cached;
+ if (exists($f->{'size'}) && -e $u) {
+ # should actually check the checksum, it's hopefully already included in the file name
+ $cached = 1 if $f->{'size'} == -s _;
}
if ($url =~ /^http[s]?:\/\/([^\/]*)\/?/ and !$cached) {
if (system($INC[0].'/download', $dir . "repodata/", $baseurl . "repodata/" . basename($u))) {
die("download failed\n");
}
}
- if ($] > 5.007) {
- require Encode;
- utf8::downgrade($u);
- }
my $fh;
open($fh, '<', $u) or die "Error opening $u: $!\n";
if ($u =~ /\.gz$/) {