From d54812ea2bb73fdded1074dc19a11dcf0b4de73f Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Fri, 26 Nov 2021 14:44:57 -0500 Subject: [PATCH] Save last download error as peer comment --- info.rkt | 2 +- tt.rkt | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/info.rkt b/info.rkt index 80282c2..22c222b 100644 --- a/info.rkt +++ b/info.rkt @@ -6,7 +6,7 @@ (define pkg-desc "twtxt client") (define version - "0.24.0") + "0.25.0") (define pkg-authors '("Siraaj Khandkar ")) (define deps diff --git a/tt.rkt b/tt.rkt index ec46623..5b10215 100644 --- a/tt.rkt +++ b/tt.rkt @@ -591,15 +591,19 @@ (concurrent-filter-map num-workers (λ (p) (cons p (peer-download timeout p))) peers)) - (define ok? (match-lambda - [(cons _ (cons 'ok _)) #t] - [(cons _ (cons 'error _)) #f])) - (define (err? r) (not (ok? r))) - (define peers-ok (map car (filter ok? results))) - (define peers-err (map car (filter err? results))) + (define peers-ok + (filter-map (match-lambda + [(cons p (cons 'ok _)) p] + [(cons _ (cons 'error e)) #f]) + results)) + (define peers-err + (filter-map (match-lambda + [(cons _ (cons 'ok _)) + #f] + [(cons p (cons 'error e)) + (struct-copy Peer p [comment (format "~s" e)])]) + results)) (peers->file peers-ok (build-path tt-home-dir "peers-last-downloaded-ok")) - ; TODO Append error as a comment: # - ; TODO Support inline/trailing comments in peer files (peers->file peers-err (build-path tt-home-dir "peers-last-downloaded-err"))) (: uniq (∀ (α) (-> (Listof α) (Listof α)))) -- 2.20.1