1
0
Fork 0

- prevented deletion of mentions when the program is in debug-mode;

- [gemini] prevented crash when and error getting data from TLS socket;
- prevented crash when dumping mentions.
This commit is contained in:
cage 2022-11-25 18:32:13 +01:00
parent 41a4787f16
commit 66c7adab15
4 changed files with 54 additions and 45 deletions

View File

@ -756,6 +756,7 @@ the latest 15 mentions)."
mentions-so-far))
(defun update-mentions-folder (&key (delete-mentions-on-server t))
(declare (ignorable delete-mentions-on-server)) ; because of the render macro '#-debug-mode'
(let ((trees '()))
(when-let* ((all-mentions (all-mentions))
(statuses (loop for mention in all-mentions
@ -773,6 +774,7 @@ the latest 15 mentions)."
:folder db:+mentions-status-folder+
:localp t
:min-id nil)))
#-debug-mode
(when delete-mentions-on-server
(loop for mention in all-mentions do
(delete-notification (tooter:id mention))))

View File

@ -429,7 +429,8 @@
(loop
named download-loop
for ct from 0
for line-as-array = (read-line-into-array download-stream)
for line-as-array = (with-print-error-message
(read-line-into-array download-stream))
while line-as-array do
(gemini-client:debug-gemini "[stream] gemini file stream raw data line : ~a"
line-as-array)
@ -493,45 +494,47 @@
(setf support-file (fs:temporary-file :extension extension)))
(with-open-support-file (file-stream support-file)
(let ((partial-content-not-opened t))
(labels ((download-completed-p (buffer read-so-far)
(< read-so-far (length buffer)))
(opening-partial-contents-p (read-so-far)
(let ((buffer-size (swconf:link-regex->program-to-use-buffer-size path)))
(if buffer-size
(> read-so-far buffer-size)
(> read-so-far swconf:+buffer-minimum-size-to-open+))))
(%fill-buffer ()
(declare (optimize (debug 0) (speed 3)))
(when (downloading-allowed-p wrapper-object)
(multiple-value-bind (program-exists y wait-for-download)
(swconf:link-regex->program-to-use support-file)
(declare (ignore y))
(multiple-value-bind (buffer read-so-far)
(read-array download-stream +read-buffer-size+)
(declare ((vector (unsigned-byte 8)) buffer))
(declare (fixnum read-so-far))
(increment-bytes-count wrapper-object read-so-far)
(if (download-completed-p buffer read-so-far)
(progn
(write-sequence buffer file-stream :start 0 :end read-so-far)
(force-output file-stream)
(setf (stream-status wrapper-object) :completed)
(gemini-client:close-ssl-socket socket)
(when (or wait-for-download
partial-content-not-opened)
(os-utils:open-resource-with-external-program support-file
nil)))
(progn
(write-sequence buffer file-stream)
(when (and partial-content-not-opened
program-exists
(not wait-for-download)
(opening-partial-contents-p (octect-count wrapper-object)))
(setf partial-content-not-opened nil)
(os-utils:open-resource-with-external-program support-file
nil))
(%fill-buffer))))))))
(%fill-buffer)))))))
(labels ((download-completed-p (buffer read-so-far)
(and buffer
(< read-so-far (length buffer))))
(opening-partial-contents-p (read-so-far)
(let ((buffer-size (swconf:link-regex->program-to-use-buffer-size path)))
(if buffer-size
(> read-so-far buffer-size)
(> read-so-far swconf:+buffer-minimum-size-to-open+))))
(%fill-buffer ()
(declare (optimize (debug 0) (speed 3)))
(when (downloading-allowed-p wrapper-object)
(multiple-value-bind (program-exists y wait-for-download)
(swconf:link-regex->program-to-use support-file)
(declare (ignore y))
(multiple-value-bind (buffer read-so-far)
(with-print-error-message
(read-array download-stream +read-buffer-size+))
(declare ((vector (unsigned-byte 8)) buffer))
(declare (fixnum read-so-far))
(increment-bytes-count wrapper-object read-so-far)
(if (download-completed-p buffer read-so-far)
(progn
(write-sequence buffer file-stream :start 0 :end read-so-far)
(force-output file-stream)
(setf (stream-status wrapper-object) :completed)
(gemini-client:close-ssl-socket socket)
(when (or wait-for-download
partial-content-not-opened)
(os-utils:open-resource-with-external-program support-file
nil)))
(progn
(write-sequence buffer file-stream)
(when (and partial-content-not-opened
program-exists
(not wait-for-download)
(opening-partial-contents-p (octect-count wrapper-object)))
(setf partial-content-not-opened nil)
(os-utils:open-resource-with-external-program support-file
nil))
(%fill-buffer))))))))
(%fill-buffer)))))))
(defun request-success-dispatched-clrs (enqueue)
(lambda (status code-description meta response socket iri parsed-iri)

View File

@ -1690,9 +1690,11 @@
(message-window specials:*message-window*))
(if mentions
(labels ((print-mention (notification)
(format nil "type: ~a from ~a"
(tooter:kind notification)
(tooter:account-name (tooter:account notification))))
(let ((raw-text (format nil
"type: ~a from ~a"
(tooter:kind notification)
(tooter:account-name (tooter:account notification)))))
(tui:make-tui-string raw-text)))
(make-rows (mentions)
(mapcar (lambda (mention)
(make-instance 'line-oriented-window:line

View File

@ -508,7 +508,8 @@ latter has a length equals to `total-size'"))
(error (e)
(ui:notify (format nil (_ "Error: ~a") e)
:life (* (swconf:config-notification-life) 5)
:as-error t))))
:as-error t)
nil)))
(defmacro with-print-error-message (&body body)
#+debug-mode `(progn ,@body)
@ -516,4 +517,5 @@ latter has a length equals to `total-size'"))
(progn
,@body)
(error (e)
(ui:error-message (format nil (_ "Error: ~a") e)))))
(ui:error-message (format nil (_ "Error: ~a") e))
nil)))