Skip to content

Commit

Permalink
Only purge in latest script if making a change
Browse files Browse the repository at this point in the history
The previous attempt to only purge changed dists in the latest script
tried to only mark for purging when marking for upgrade or downgrade.
But the if conditions to mark for upgrade/downgrade is not all of the
logic. There are later conditions to limit which dists will be upgraded.

Move the code marking dists to purge until after this later filtering.
  • Loading branch information
haarg committed Feb 26, 2024
1 parent b1625ce commit f078e8d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/MetaCPAN/Script/Latest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ sub run {

my %upgrade;
my %downgrade;
my @modules_to_purge;
my %queued_distributions;

my $total = @filter;
Expand Down Expand Up @@ -202,11 +201,9 @@ sub run {
)
);
$upgrade{ $file_data->{distribution} } = $file_data;
push @modules_to_purge, @modules;
}
elsif ( $file_data->{status} eq 'latest' ) {
$downgrade{ $file_data->{release} } = $file_data;
push @modules_to_purge, @modules;
}
}
}
Expand All @@ -217,12 +214,16 @@ sub run {
type => 'file'
);

my %to_purge;

while ( my ( $dist, $file_data ) = each %upgrade ) {

# Don't reindex if already marked as latest.
# This just means that it hasn't changed (query includes 'latest').
next if ( !$self->force and $file_data->{status} eq 'latest' );

$to_purge{ $file_data->{download_url} } = 1;

$self->reindex( $bulk, $file_data, 'latest' );
}

Expand All @@ -238,17 +239,16 @@ sub run {
&& $upgrade{ $file_data->{distribution} }->{release} eq
$file_data->{release} );

$to_purge{ $file_data->{download_url} } = 1;

$self->reindex( $bulk, $file_data, 'cpan' );
}
$bulk->flush;
$self->index->refresh;

# We just want the CPAN::DistnameInfo
my @module_to_purge_dists = map { $_->distribution } @modules_to_purge;

# Call Fastly to purge
$self->purge_cpan_distnameinfos( \@module_to_purge_dists );

$self->purge_cpan_distnameinfos( [
map CPAN::DistnameInfo->new($_), keys %to_purge ] );
}

# Update the status for the release and all the files.
Expand Down

0 comments on commit f078e8d

Please sign in to comment.