local-time?)])
(+ ts-epoch tz-offset))]
[_
- (log-error "Invalid timestamp: ~v" ts)
+ (log-debug "Invalid timestamp: ~v" ts)
#f]))))
(: str->msg (-> (Option String) Url String (Option Msg)))
(with-handlers*
([exn:fail?
(λ (e)
- (log-error
+ (log-debug
"Failed to parse msg: ~v, from: ~v, at: ~v, because: ~v"
str-head nick (url->string uri) e)
#f)])
(regexp-match* #px"@<[^\\s]+([\\s]+)?[^>]+>" text))])
(Msg ts-epoch ts-orig nick uri text mentions))
(begin
- (log-error
+ (log-debug
"Msg rejected due to invalid timestamp: ~v, nick:~v, uri:~v"
str-head nick (url->string uri))
#f)))]
(if (file-exists? path-v2)
(file->string path-v2)
(begin
- (log-warning "Cache file not found for URI: ~a" (url->string uri))
+ (log-debug "Cache file not found for URI: ~a" (url->string uri))
#f)))
(: str->url (-> String (Option String)))
#f]
[url (Peer nick url comment)])]
[_
- (log-error "Invalid peer string: ~v" str)
+ (log-debug "Invalid peer string: ~v" str)
#f]))
(module+ test
(log-debug "Last-Modified <= current skipping the rest of ~v" u-str)
#t))))
(if (not cached?)
- (begin
- (log-debug
- "Downloading the rest of ~v. ETag: ~a, Last-Modified: ~v"
- u-str etag lmod)
- (make-parent-directory* cached-object-path)
- (make-parent-directory* cached-etag-path)
- (make-parent-directory* cached-lmod-path)
- (call-with-output-file cached-object-path
- (curry copy-port body-input)
- #:exists 'replace)
- (when etag
- (display-to-file etag cached-etag-path #:exists 'replace))
- (when lmod
- (display-to-file lmod cached-lmod-path #:exists 'replace))
- 'downloaded-new)
- 'skipped-cached))
+ (begin
+ (log-debug
+ "Downloading the rest of ~v. ETag: ~a, Last-Modified: ~v"
+ u-str etag lmod)
+ (make-parent-directory* cached-object-path)
+ (make-parent-directory* cached-etag-path)
+ (make-parent-directory* cached-lmod-path)
+ (call-with-output-file cached-object-path
+ (curry copy-port body-input)
+ #:exists 'replace)
+ (when etag
+ (display-to-file etag cached-etag-path #:exists 'replace))
+ (when lmod
+ (display-to-file lmod cached-lmod-path #:exists 'replace))
+ 'downloaded-new)
+ 'skipped-cached))
(: uri-download
(-> Positive-Float Url
(: peer->msgs (-> Peer (Listof Msg)))
(define (peer->msgs peer)
(match-define (Peer nick uri _) peer)
- (log-info "Reading peer nick:~v uri:~v" nick (url->string uri))
+ (log-debug "Reading peer nick:~v uri:~v" nick (url->string uri))
(define msgs-data (uri-read-cached uri))
+ ; TODO Expire cache
(if msgs-data
(str->msgs nick uri msgs-data)
'()))
(: mentioned-peers-in-cache (-> (Listof Peer)))
(define (mentioned-peers-in-cache)
+ ; TODO Expire cache
(define msgs
(append* (map (λ (filename)
(define path (build-path cache-object-dir filename))
(define size (/ (file-size path) 1000000.0))
- (log-info "BEGIN parsing ~a MB from file: ~v"
+ (log-debug "BEGIN parsing ~a MB from file: ~v"
size
(path->string path))
(define t0 (current-inexact-milliseconds))
(filter-comments
(file->lines path))))
(define t1 (current-inexact-milliseconds))
- (log-info "END parsing ~a MB in ~a seconds from file: ~v."
+ (log-debug "END parsing ~a MB in ~a seconds from file: ~v."
size
(* 0.001 (- t1 t0))
(path->string path))
(when (empty? m)
- (log-warning "No messages found in ~a" (path->string path)))
+ (log-debug "No messages found in ~a" (path->string path)))
m)
(directory-list cache-object-dir))))
(uniq (append* (map Msg-mentions msgs))))
"r, read : Read the timeline (offline operation)."
"d, download : Download the timeline."
; TODO Add path dynamically
- "u, upload : Upload your twtxt file (alias to execute ~/.tt/upload)."
+ "u, upload : Upload your twtxt file (alias to execute ~/.tt/hooks/upload)."
"c, crawl : Discover new peers mentioned by known peers (offline operation)."
""
#:args (command . args)
#:program
"tt upload"
#:args ()
- (if (system (path->string (build-path tt-home-dir "upload")))
+ (if (system (path->string (build-path tt-home-dir "hooks" "upload")))
(exit 0)
(exit 1)))]
[(or "r" "read")
(filter
(λ (p) (< 0 (length (peer->msgs p))))
peers-all)])
+ ; TODO Deeper de-duping
(log-info "Known peers mentioned: ~a" (length peers-mentioned))
(log-info "Known peers parsed ~a" (length peers-parsed))
(log-info "Known peers total: ~a" (length peers-all))