diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index d64c300..5cf2e93 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -1171,12 +1171,12 @@ local file paths." ((or (gemini-parser:gemini-iri-p actual-iri) needs-proxy) (let ((stream-frame (stream-frame main-window))) - ;; note: keeps this call before 'start-stream-iri', the + ;; note: keeps this call before 'start-stream-iri'; the ;; latter will recursively call 'open-iri' (this ;; function) if a redirect is met, and the procedures to ;; delete and repopulate stream frames gets interleaved - ;; in nodgui, I have to investigate - ;; why. + ;; in nodgui because of the same procedure called in + ;; 'slurp-gemini-stream', but in a different thread. (client-stream-frame::refresh-all-streams (client-stream-frame::table stream-frame)) (start-stream-iri (iri-ensure-path actual-iri) @@ -1241,23 +1241,26 @@ local file paths." (defun slurp-non-text-data (main-window iri &key (try-to-open t)) (declare (optimize (debug 0) (speed 3))) - (labels ((wait-until-download-complete (stream-info support-file) + (labels ((stream-completed-p (stream-info) + (string-equal (getf stream-info :stream-status) + :completed)) + (wait-until-download-complete (stream-info support-file) (declare (optimize (debug 0) (speed 3))) - (if (string-equal (getf stream-info :stream-status) - :completed) + (if (stream-completed-p stream-info) (if try-to-open (client-os-utils:open-resource-with-external-program main-window support-file) (values (getf stream-info :support-file) (getf stream-info :meta))) (wait-enough-data))) - (buffer-filled-enough-to-open-p (buffer-size read-so-far) + (buffer-filled-enough-to-open-p (buffer-size read-so-far stream-info) (declare (optimize (debug 0) (speed 3))) (declare (fixnum buffer-size read-so-far)) (let ((filled-configuration-threshold (and buffer-size (> read-so-far buffer-size)))) (or filled-configuration-threshold (> read-so-far - swconf:+buffer-minimum-size-to-open+)))) + swconf:+buffer-minimum-size-to-open+) + (stream-completed-p stream-info)))) (wait-enough-data () (declare (optimize (debug 0) (speed 3))) (let* ((stream-info @@ -1265,8 +1268,8 @@ local file paths." 1 ev:+maximum-event-priority+ iri)) - (read-so-far (getf stream-info :octet-count -1)) - (support-file (getf stream-info :support-file))) + (read-so-far (getf stream-info :octet-count -1)) + (support-file (getf stream-info :support-file))) (multiple-value-bind (program-exists y wait-for-download) (swconf:link-regex->program-to-use support-file) (declare (ignore y)) @@ -1275,7 +1278,9 @@ local file paths." (not try-to-open)) (wait-until-download-complete stream-info support-file) (let ((buffer-size (swconf:link-regex->program-to-use-buffer-size support-file))) - (if (buffer-filled-enough-to-open-p buffer-size read-so-far) + (if (buffer-filled-enough-to-open-p buffer-size + read-so-far + stream-info) (client-os-utils:open-resource-with-external-program main-window support-file) (wait-enough-data))))