From 40767c22562162dde3519a78e6590e52caf81643 Mon Sep 17 00:00:00 2001 From: saturn Date: Tue, 9 Feb 2021 09:35:38 -0600 Subject: [PATCH] Switch to Drakma for downloading images. --- lw2-viewer.asd | 2 +- src/images.lisp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lw2-viewer.asd b/lw2-viewer.asd index 3ae55139..3a1f1f74 100644 --- a/lw2-viewer.asd +++ b/lw2-viewer.asd @@ -1,7 +1,7 @@ (in-package :asdf) (asdf:defsystem :lw2-viewer - :depends-on ("uiop" "flexi-streams" "hunchentoot" "dexador" "cl-json" "lmdb" "local-time" "plump" "clss" "cl-ppcre" "xml-emitter" "city-hash" "bit-smasher" "cl-unicode" "parse-js" "cl-markdown" "websocket-driver-client" "ironclad" "cl-base64" "djula" "split-sequence" "cl-typesetting" "named-readtables" "collectors" "closer-mop" "chronicity" "parenscript" "trivial-gray-streams" "trivia" "iterate" "introspect-environment" "trivial-macroexpand-all" "trivial-cltl2" "dufy/core") + :depends-on ("uiop" "flexi-streams" "hunchentoot" "dexador" "drakma" "cl-json" "lmdb" "local-time" "plump" "clss" "cl-ppcre" "xml-emitter" "city-hash" "bit-smasher" "cl-unicode" "parse-js" "cl-markdown" "websocket-driver-client" "ironclad" "cl-base64" "djula" "split-sequence" "cl-typesetting" "named-readtables" "collectors" "closer-mop" "chronicity" "parenscript" "trivial-gray-streams" "trivia" "iterate" "introspect-environment" "trivial-macroexpand-all" "trivial-cltl2" "dufy/core") :components ((:module "src" :components ((:file "utils" :depends-on ("macro-utils")) (:file "macro-utils") diff --git a/src/images.lisp b/src/images.lisp index f3c7dc9a..89c02080 100644 --- a/src/images.lisp +++ b/src/images.lisp @@ -52,10 +52,11 @@ (uiop:run-program (list "convert" input "-colorspace" "Lab" "-channel" "R" "-negate" "-gamma" "2.2" "-colorspace" "sRGB" output)))) (defun download-file (uri target) - (dynamic-flet ((use-response (response-stream) - (with-open-file (out-stream target :direction :output :if-exists :supersede :element-type '(unsigned-byte 8)) - (alexandria:copy-stream response-stream out-stream)))) - (lw2.backend:call-with-http-response #'use-response uri :want-stream t :keep-alive nil :force-binary t :headers (alist :accept "image/*,*/*")))) + (with-open-file (out-stream target :direction :output :if-exists :supersede :element-type '(unsigned-byte 8)) + (let ((in-stream (drakma:http-request uri :want-stream t :force-binary t :accept "image/*,*/*"))) + (unwind-protect + (alexandria:copy-stream in-stream out-stream) + (close in-stream))))) (define-cache-database 'lw2.backend-modules:backend-lmdb-cache "dynamic-content-images" "cached-images") -- 2.11.4.GIT