Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Exit early from the retry loop if the status is ok or 404
  • Loading branch information
abhi3315 committed Apr 26, 2024
commit 742714deb45e204c64950ec7d98e9c3c215bdd29
10 changes: 10 additions & 0 deletions src/Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ function () use ( $temp ) {
$status_code = (int) $response->status_code;
$is_response_ok = $status_code >= 200 && $status_code < 300;

// Exit the loop if the response is OK or the status code is 404.
if ( $is_response_ok || 404 === $status_code ) {
$retry = 0;
}

if ( 404 === $status_code ) {
WP_CLI::error( 'Release not found. Double-check locale or version.' );
} elseif ( ! $is_response_ok ) {
Expand All @@ -324,6 +329,11 @@ function () use ( $temp ) {
$status_code = (int) $md5_response->status_code;
$is_response_ok = $status_code >= 200 && $status_code < 300;

// Exit the loop if the response is OK or the status code is 404.
if ( $is_response_ok || 404 === $status_code ) {
$retry = 0;
}

if ( $is_response_ok ) {
$md5_file = md5_file( $temp );

Expand Down