Commit 9d9bcb50 authored by Ulf Jasper's avatar Ulf Jasper Committed by Ulf Jasper
Browse files

Newsticker: fix broken image download via url-retrieve, again.

* lisp/net/newst-backend.el
(newsticker--image-download-by-url-callback): Make this function
actually work: Check status properly, then save image.
parent 56dfc811
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
   
* net/newst-backend.el * net/newst-backend.el
(newsticker--image-download-by-url-callback): Make this function (newsticker--image-download-by-url-callback): Make this function
actually work: First save image then check status. actually work: Check status properly, then save image.
   
2014-10-20 Stefan Monnier <monnier@iro.umontreal.ca> 2014-10-20 Stefan Monnier <monnier@iro.umontreal.ca>
   
......
...@@ -1806,7 +1806,7 @@ download it from URL first." ...@@ -1806,7 +1806,7 @@ download it from URL first."
(if (and (file-exists-p image-name) (if (and (file-exists-p image-name)
(time-less-p (current-time) (time-less-p (current-time)
(time-add (nth 5 (file-attributes image-name)) (time-add (nth 5 (file-attributes image-name))
(seconds-to-time 86400)))) (seconds-to-time 86400))))
(newsticker--debug-msg "%s: Getting image for %s skipped" (newsticker--debug-msg "%s: Getting image for %s skipped"
(format-time-string "%A, %H:%M" (current-time)) (format-time-string "%A, %H:%M" (current-time))
feed-name) feed-name)
...@@ -1905,29 +1905,29 @@ STATUS is the return status as delivered by `url-retrieve'. ...@@ -1905,29 +1905,29 @@ STATUS is the return status as delivered by `url-retrieve'.
FEED-NAME is the name of the feed that the news were retrieved FEED-NAME is the name of the feed that the news were retrieved
from. from.
The image is saved in DIRECTORY as FILENAME." The image is saved in DIRECTORY as FILENAME."
(let ((buf (get-buffer-create (concat " *newsticker-url-image-" feed-name "-" (let ((do-save
directory "*"))) (or (not status)
(result (string-to-multibyte (buffer-string)))) (let ((status-type (car status))
(set-buffer buf) (status-details (cdr status)))
(erase-buffer) (cond ((eq status-type :redirect)
(insert result) ;; don't care about redirects
;; remove MIME header t)
(goto-char (point-min)) ((eq status-type :error)
(search-forward "\n\n") ;; silently ignore errors
(delete-region (point-min) (point)) nil))))))
;; save (when do-save
(newsticker--image-save buf directory filename)) (let ((buf (get-buffer-create (concat " *newsticker-url-image-" feed-name "-"
(when status directory "*")))
(let ((status-type (car status)) (result (string-to-multibyte (buffer-string))))
(status-details (cdr status))) (set-buffer buf)
(cond ((eq status-type :redirect) (erase-buffer)
;; don't care about redirects (insert result)
) ;; remove MIME header
((eq status-type :error) (goto-char (point-min))
(message "%s: Error while retrieving image from %s: %s: \"%s\"" (search-forward "\n\n")
(format-time-string "%A, %H:%M" (current-time)) (delete-region (point-min) (point))
feed-name ;; save
(car status-details) (cdr status-details))))))) (newsticker--image-save buf directory filename)))))
(defun newsticker--insert-image (img string) (defun newsticker--insert-image (img string)
"Insert IMG with STRING at point." "Insert IMG with STRING at point."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment