- (log-info "uri-fetch new ~a" uri)
- ; TODO Timeout. Currently hangs on slow connections.
- (let* ([resp (http-get uri)]
- [status (http-response-code resp)]
- [body (http-response-body resp)])
- (log-debug "finished GET ~a status:~a body length:~a"
- uri status (string-length body))
- ; TODO Handle redirects
- (if (= status 200)
- (begin
- (display-to-file body cache-file-path #:exists 'replace)
- body)
- ; TODO A more-informative exception
- (raise status))))))
+ (log-warning "Cache file not found for URI: ~a" uri)
+ "")))
+
+; uri-download : String -> Void
+(define (uri-download uri)
+ (define cache-file-path
+ (expand-user-path (string-append "~/.tt/cache/" (hash-sha1 uri))))
+ (log-info "uri-download ~a" uri)
+ ; TODO Timeout. Currently hangs on slow connections.
+ (let* ([resp (http-get uri)]
+ [status (http-response-code resp)]
+ [body (http-response-body resp)])
+ (log-debug "finished GET ~a status:~a body length:~a"
+ uri status (string-length body))
+ ; TODO Handle redirects
+ (if (= status 200)
+ (display-to-file body cache-file-path #:exists 'replace)
+ ; TODO A more-informative exception
+ (raise status))))