Skip to content

Commit cd61f97

Browse files
committed
Check if distribution exists before creating
This is fixing the flood of errors exposed by the Log4Perl change.
1 parent d13408d commit cd61f97

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/MetaCPAN/Model/Release.pm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ has status => (
122122
isa => Str,
123123
);
124124

125+
has es => ( is => 'ro' );
125126
has bulk => ( is => 'ro' );
126127

127128
=head2 run
@@ -221,11 +222,16 @@ sub _build_document {
221222
$document
222223
= $self->index->type('release')->put( $document, { refresh => 1 } );
223224

224-
# create will die if the document already exists
225-
eval {
225+
# create distribution if doesn't exist
226+
my $dist_count = $self->es->count(
227+
index => 'cpan',
228+
type => 'distribution',
229+
body => { query => { term => { name => $self->distribution } } },
230+
);
231+
if ( !$dist_count->{count} ) {
226232
$self->index->type('distribution')
227233
->put( { name => $self->distribution }, { create => 1 } );
228-
};
234+
}
229235
return $document;
230236
}
231237

lib/MetaCPAN/Script/Release.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ sub _get_release_model {
228228
my $d = CPAN::DistnameInfo->new($archive_path);
229229

230230
my $model = MetaCPAN::Model::Release->new(
231+
es => $self->es,
231232
bulk => $bulk,
232233
distinfo => $d,
233234
file => $archive_path,

0 commit comments

Comments
 (0)