From: Siraaj Khandkar Date: Fri, 26 Nov 2021 19:44:57 +0000 (-0500) Subject: Save last download error as peer comment X-Git-Tag: 0.26.0~2 X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=d54812ea2bb73fdded1074dc19a11dcf0b4de73f;p=tt.git Save last download error as peer comment --- 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 α))))