[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r118167: Newsticker: fix broken image download via u
From: |
Ulf Jasper |
Subject: |
[Emacs-diffs] trunk r118167: Newsticker: fix broken image download via url-retrieve, again. |
Date: |
Mon, 20 Oct 2014 19:47:57 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 118167
revision-id: address@hidden
parent: address@hidden
author: Ulf Jasper
committer: Ulf Jasper <address@hidden>
branch nick: trunk
timestamp: Mon 2014-10-20 21:47:51 +0200
message:
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.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/net/newst-backend.el
newstbackend.el-20091113204419-o5vbwnq5f7feedwu-8682
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-10-20 18:39:58 +0000
+++ b/lisp/ChangeLog 2014-10-20 19:47:51 +0000
@@ -2,7 +2,7 @@
* net/newst-backend.el
(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 <address@hidden>
=== modified file 'lisp/net/newst-backend.el'
--- a/lisp/net/newst-backend.el 2014-10-20 18:39:58 +0000
+++ b/lisp/net/newst-backend.el 2014-10-20 19:47:51 +0000
@@ -1806,7 +1806,7 @@
(if (and (file-exists-p image-name)
(time-less-p (current-time)
(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"
(format-time-string "%A, %H:%M" (current-time))
feed-name)
@@ -1905,29 +1905,29 @@
FEED-NAME is the name of the feed that the news were retrieved
from.
The image is saved in DIRECTORY as FILENAME."
- (let ((buf (get-buffer-create (concat " *newsticker-url-image-" feed-name "-"
- directory "*")))
- (result (string-to-multibyte (buffer-string))))
- (set-buffer buf)
- (erase-buffer)
- (insert result)
- ;; remove MIME header
- (goto-char (point-min))
- (search-forward "\n\n")
- (delete-region (point-min) (point))
- ;; save
- (newsticker--image-save buf directory filename))
- (when status
- (let ((status-type (car status))
- (status-details (cdr status)))
- (cond ((eq status-type :redirect)
- ;; don't care about redirects
- )
- ((eq status-type :error)
- (message "%s: Error while retrieving image from %s: %s: \"%s\""
- (format-time-string "%A, %H:%M" (current-time))
- feed-name
- (car status-details) (cdr status-details)))))))
+ (let ((do-save
+ (or (not status)
+ (let ((status-type (car status))
+ (status-details (cdr status)))
+ (cond ((eq status-type :redirect)
+ ;; don't care about redirects
+ t)
+ ((eq status-type :error)
+ ;; silently ignore errors
+ nil))))))
+ (when do-save
+ (let ((buf (get-buffer-create (concat " *newsticker-url-image-"
feed-name "-"
+ directory "*")))
+ (result (string-to-multibyte (buffer-string))))
+ (set-buffer buf)
+ (erase-buffer)
+ (insert result)
+ ;; remove MIME header
+ (goto-char (point-min))
+ (search-forward "\n\n")
+ (delete-region (point-min) (point))
+ ;; save
+ (newsticker--image-save buf directory filename)))))
(defun newsticker--insert-image (img string)
"Insert IMG with STRING at point."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r118167: Newsticker: fix broken image download via url-retrieve, again.,
Ulf Jasper <=