aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2015-06-14 22:48:18 +0100
committerArtur Malabarba2015-06-14 22:48:18 +0100
commit3881af45bf104f54a851dc84becd0a6f744839c3 (patch)
treeeb75eb226c9a05fb13bc61f7ba8d88984dc9ebea
parent2f09f8952489b5c90488faf66f71a4252aed5c2c (diff)
downloademacs-3881af45bf104f54a851dc84becd0a6f744839c3.tar.gz
emacs-3881af45bf104f54a851dc84becd0a6f744839c3.zip
* lisp/emacs-lisp/package.el (package--with-work-buffer-async):
Catch errors that happen before going async. (Bug#20809)
-rw-r--r--lisp/emacs-lisp/package.el43
1 files changed, 25 insertions, 18 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 981f42cedb5..6827cc9d17f 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1119,9 +1119,11 @@ buffer is killed afterwards. Return the last value in BODY."
1119 "Run BODY in a buffer containing the contents of FILE at LOCATION. 1119 "Run BODY in a buffer containing the contents of FILE at LOCATION.
1120If ASYNC is non-nil, and if it is possible, run BODY 1120If ASYNC is non-nil, and if it is possible, run BODY
1121asynchronously. If an error is encountered and ASYNC is a 1121asynchronously. If an error is encountered and ASYNC is a
1122function, call it with no arguments (instead of executing BODY), 1122function, call it with no arguments (instead of executing BODY).
1123otherwise propagate the error. For description of the other 1123The error is propagated either way.
1124arguments see `package--with-work-buffer'." 1124
1125For a description of the other arguments see
1126`package--with-work-buffer'."
1125 (declare (indent 3) (debug t)) 1127 (declare (indent 3) (debug t))
1126 (macroexp-let2* macroexp-copyable-p 1128 (macroexp-let2* macroexp-copyable-p
1127 ((async-1 async) 1129 ((async-1 async)
@@ -1130,21 +1132,26 @@ arguments see `package--with-work-buffer'."
1130 `(if (or (not ,async-1) 1132 `(if (or (not ,async-1)
1131 (not (string-match-p "\\`https?:" ,location-1))) 1133 (not (string-match-p "\\`https?:" ,location-1)))
1132 (package--with-work-buffer ,location-1 ,file-1 ,@body) 1134 (package--with-work-buffer ,location-1 ,file-1 ,@body)
1133 (url-retrieve (concat ,location-1 ,file-1) 1135 ;; This `condition-case' is to catch connection errors.
1134 (lambda (status) 1136 (condition-case error-signal
1135 (if (eq (car status) :error) 1137 (url-retrieve (concat ,location-1 ,file-1)
1136 (if (functionp ,async-1) 1138 (lambda (status)
1137 (funcall ,async-1) 1139 (if (eq (car status) :error)
1138 (signal (cdar status) (cddr status))) 1140 (progn (if (functionp ,async-1)
1139 (goto-char (point-min)) 1141 (funcall ,async-1))
1140 (unless (search-forward "\n\n" nil 'noerror) 1142 (signal (cdar status) (cddr status)))
1141 (error "Invalid url response in buffer %s" 1143 (goto-char (point-min))
1142 (current-buffer))) 1144 (unless (search-forward "\n\n" nil 'noerror)
1143 (delete-region (point-min) (point)) 1145 (error "Invalid url response in buffer %s"
1144 ,@body) 1146 (current-buffer)))
1145 (kill-buffer (current-buffer))) 1147 (delete-region (point-min) (point))
1146 nil 1148 ,@body)
1147 'silent)))) 1149 (kill-buffer (current-buffer)))
1150 nil
1151 'silent)
1152 (error (when (functionp ,async-1)
1153 (funcall ,async-1))
1154 (signal (car error-signal) (cdr error-signal)))))))
1148 1155
1149(defun package--check-signature-content (content string &optional sig-file) 1156(defun package--check-signature-content (content string &optional sig-file)
1150 "Check signature CONTENT against STRING. 1157 "Check signature CONTENT against STRING.