diff --git a/bin/mirror-ckan b/bin/mirror-ckan index 32a9d44..bec693b 100644 --- a/bin/mirror-ckan +++ b/bin/mirror-ckan @@ -114,6 +114,7 @@ sub yesterday { $mirror->upload_ckan($file); }; } + sleep 1; # We're going to be checking 100s, lets not overwhelm the API } exit 0; diff --git a/lib/App/KSP_CKAN/WebHooks.pm b/lib/App/KSP_CKAN/WebHooks.pm index 80fdb85..d350fff 100644 --- a/lib/App/KSP_CKAN/WebHooks.pm +++ b/lib/App/KSP_CKAN/WebHooks.pm @@ -55,8 +55,12 @@ post '/gh/:task' => sub { } my @commits; + my $sender; + my $json; try { - @commits = @{from_json(request->body)->{commits}}; + $json = from_json(request->body); + @commits = @{$json->{commits}}; + $sender = $json->{sender}{login}; }; if ( $#commits == -1 && $task ne "release" ) { @@ -64,6 +68,12 @@ post '/gh/:task' => sub { return { "message" => "No add/remove commits received" }; } + if ( defined $sender && $sender eq 'kspckan-crawler' ) { + info("Commits sent by crawler, skipping on demand mirror"); + status(204); + return; + } + if ( $task eq "inflate" ) { inflate_github(commits => \@commits); } elsif ( $task eq "mirror" ) {