Re-org peer set file names and locations 0.29.1
authorSiraaj Khandkar <siraaj@khandkar.net>
Wed, 1 Dec 2021 01:48:16 +0000 (20:48 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Wed, 1 Dec 2021 01:48:16 +0000 (20:48 -0500)
info.rkt
tt.rkt

index dc8a3af..350fb77 100644 (file)
--- a/info.rkt
+++ b/info.rkt
@@ -6,7 +6,7 @@
 (define pkg-desc
   "twtxt client")
 (define version
-  "0.29.0")
+  "0.29.1")
 (define pkg-authors
   '("Siraaj Khandkar <siraaj@khandkar.net>"))
 (define deps
diff --git a/tt.rkt b/tt.rkt
index e002e71..d8918e6 100644 (file)
--- a/tt.rkt
+++ b/tt.rkt
 (: tt-home-dir Path-String)
 (define tt-home-dir (build-path (expand-user-path "~") ".tt"))
 
+(: pub-peers-dir Path-String)
+(define pub-peers-dir (build-path tt-home-dir "peers"))
+
 (: concurrent-filter-map (∀ (α β) (-> Natural (-> α β) (Listof α) (Listof β))))
 (define (concurrent-filter-map num-workers f xs)
   ; TODO preserve order of elements OR communicate that reorder is expected
 
 (: peers->file (-> (Listof Peers) Path-String Void))
 (define (peers->file peers path)
+  (make-parent-directory* path)
   (display-lines-to-file
     (map peer->str
          (sort peers
                   [(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"))
-  (peers->file peers-err (build-path tt-home-dir "peers-last-downloaded-err")))
+  (peers->file peers-ok (build-path tt-home-dir "peers-last-downloaded-ok.txt"))
+  (peers->file peers-err (build-path tt-home-dir "peers-last-downloaded-err.txt")))
 
 (: peers->timeline (-> (Listof Peer) (Listof Msg)))
 (define (peers->timeline peers)
 (define (paths->peers paths)
   (let* ([paths (match paths
                   ['()
-                   (let ([peer-refs-file (build-path tt-home-dir "peers")])
+                   (let ([peer-refs-file (build-path tt-home-dir "following.txt")])
                      (log-debug
                        "No peer ref file paths provided, defaulting to ~v"
                        (path->string peer-refs-file))
   (hash-for-each
     nick-hist
     (λ (url nick->hist)
-       (define path (build-path tt-home-dir "nicks" "seen" (uri-encode (url->string url))))
-       (make-parent-directory* path)
+       (define filename (string-append (uri-encode (url->string url)) ".txt"))
+       (define filepath (build-path tt-home-dir "nicks" "seen" filename))
+       (make-parent-directory* filepath)
        (display-lines-to-file
          (map (match-lambda
                 [(cons nick (Hist freq last))
                     (match-lambda**
                       [((cons _ (Hist a _)) (cons _ (Hist b _)))
                        (> a b)])))
-         path
+         filepath
          #:exists 'replace))))
 
 (: nick-hist-most-by (-> Nick-Hist Url (-> Hist Nonnegative-Integer) (Option String)))
 (define (crawl)
   ; TODO Test the non-io parts of crawling
   (let* ([peers-all-file
-           (build-path tt-home-dir "peers-all")]
+           (build-path pub-peers-dir "all.txt")]
          [peers-mentioned-file
-           (build-path tt-home-dir "peers-mentioned")]
+           (build-path pub-peers-dir "mentioned.txt")]
          [peers-parsed-file
-           (build-path tt-home-dir "peers-parsed")]
+           (build-path pub-peers-dir "downloaded-and-parsed.txt")]
          [peers-cached-file
-           (build-path tt-home-dir "peers-cached")]
+           (build-path pub-peers-dir "downloaded.txt")]
          [peers-cached
            (peers-cached)]
          [cached-timeline
       #:args (command . args)
       (define log-writer (log-writer-start log-level))
       (current-command-line-arguments (list->vector args))
-      (set-user-agent-str (build-path tt-home-dir "me"))
+      (set-user-agent-str (build-path tt-home-dir "user.txt"))
       ; TODO dispatch should return status with which we should exit after cleanups
       (dispatch command)
       (log-writer-stop log-writer))))
This page took 0.022537 seconds and 4 git commands to generate.