From d2490c5828cd8b90ae1fd64475488b650d923f43 Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Wed, 24 Nov 2021 00:57:06 +0700 Subject: [PATCH] fix check-urls --- .github/workflows/check-urls.yml | 3 --- check_urls/main.dart | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-urls.yml b/.github/workflows/check-urls.yml index a6c0bf5..c28d9d8 100644 --- a/.github/workflows/check-urls.yml +++ b/.github/workflows/check-urls.yml @@ -35,9 +35,6 @@ jobs: - name: Run check_urls/main.dart run: dart run main.dart - - name: Run example/lib/rxdart_ext_example.dart - run: dart run example/lib/rxdart_ext_example.dart - run-example: runs-on: ubuntu-latest defaults: diff --git a/check_urls/main.dart b/check_urls/main.dart index 293b25b..39dc088 100644 --- a/check_urls/main.dart +++ b/check_urls/main.dart @@ -37,10 +37,24 @@ Future testUrl(Uri url) async { return success; } +Future testUrlWithRetry(Uri url) async { + var retryCount = 0; + while (true) { + final success = await testUrl(url); + if (success) { + return true; + } + if (retryCount++ >= 3) { + return false; + } + } +} + Future> test(Iterable urls) { return Stream.fromIterable(urls) .map(Uri.parse) - .asyncMap((url) => testUrl(url).then((success) => success ? null : url)) + .asyncMap((url) => + testUrlWithRetry(url).then((success) => success ? null : url)) .where((url) => url != null) .cast() .toList();