diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-12-16 22:15:37 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-12-16 22:15:37 +0100 |
commit | bb22915fc3816645e4de83a88b0ac016e51924d9 (patch) | |
tree | 11d842d99ef40eac4517dab2650b75b6638d910f | |
parent | cabf159f46e5027e6191f82d3621b9ba9898cb61 (diff) |
Fix has_wagonorder_p logic. request success ≠ result success!
-rwxr-xr-x | lib/Travelynx.pm | 17 |
1 files 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 { |