From bb22915fc3816645e4de83a88b0ac016e51924d9 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 16 Dec 2019 22:15:37 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20has=5Fwagonorder=5Fp=20logic.=20request?= =?UTF-8?q?=20success=20=E2=89=A0=20result=20success!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Travelynx.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 9f1a3a8..df02485 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1838,7 +1838,11 @@ sub startup { my $promise = Mojo::Promise->new; if ( my $content = $cache->get($url) ) { - if ( $content eq 'n' ) { + if ( $content eq 'y' ) { + $promise->resolve; + return $promise; + } + elsif ( $content eq 'n' ) { $promise->reject; return $promise; } @@ -1846,8 +1850,15 @@ sub startup { $self->ua->request_timeout(5)->head_p($url)->then( sub { - $cache->set( $url, 'y' ); - $promise->resolve; + my ($tx) = @_; + if ( $tx->result->is_success ) { + $cache->set( $url, 'y' ); + $promise->resolve; + } + else { + $cache->set( $url, 'n' ); + $promise->resolve; + } } )->catch( sub {