(when (file-exists-p mail-source-crash-box)
(message "Processing mail from %s..." mail-source-crash-box)
(setq found (mail-source-callback
- callback mail-source-crash-box)))
+ callback mail-source-crash-box))
+ (mail-source-delete-crash-box))
(+ found
(if (or debug-on-quit debug-on-error)
(funcall function source callback)
(delete-file ffile))))))
(defun mail-source-callback (callback info)
- "Call CALLBACK on the mail file, and then remove the mail file.
-Pass INFO on to CALLBACK."
+ "Call CALLBACK on the mail file. Pass INFO on to CALLBACK."
(if (or (not (file-exists-p mail-source-crash-box))
(zerop (nth 7 (file-attributes mail-source-crash-box))))
(progn
(when (file-exists-p mail-source-crash-box)
(delete-file mail-source-crash-box))
0)
- (prog1
- (funcall callback mail-source-crash-box info)
- (when (file-exists-p mail-source-crash-box)
- ;; Delete or move the incoming mail out of the way.
- (if (eq mail-source-delete-incoming t)
- (delete-file mail-source-crash-box)
- (let ((incoming
- (mm-make-temp-file
- (expand-file-name
- mail-source-incoming-file-prefix
- mail-source-directory))))
- (unless (file-exists-p (file-name-directory incoming))
- (make-directory (file-name-directory incoming) t))
- (rename-file mail-source-crash-box incoming t)
- ;; remove old incoming files?
- (when (natnump mail-source-delete-incoming)
- (mail-source-delete-old-incoming
- mail-source-delete-incoming
- mail-source-delete-old-incoming-confirm))))))))
+ (funcall callback mail-source-crash-box info)))
+
+(defun mail-source-delete-crash-box ()
+ (when (file-exists-p mail-source-crash-box)
+ ;; Delete or move the incoming mail out of the way.
+ (if (eq mail-source-delete-incoming t)
+ (delete-file mail-source-crash-box)
+ (let ((incoming
+ (mm-make-temp-file
+ (expand-file-name
+ mail-source-incoming-file-prefix
+ mail-source-directory))))
+ (unless (file-exists-p (file-name-directory incoming))
+ (make-directory (file-name-directory incoming) t))
+ (rename-file mail-source-crash-box incoming t)
+ ;; remove old incoming files?
+ (when (natnump mail-source-delete-incoming)
+ (mail-source-delete-old-incoming
+ mail-source-delete-incoming
+ mail-source-delete-old-incoming-confirm))))))
(defun mail-source-movemail (from to)
"Move FROM to TO using movemail."
(prog1
(mail-source-callback callback path)
(mail-source-run-script
- postscript (format-spec-make ?t mail-source-crash-box)))
+ postscript (format-spec-make ?t mail-source-crash-box))
+ (mail-source-delete-crash-box))
0))))
(defun mail-source-fetch-directory (source callback)
(when (and (file-regular-p file)
(funcall predicate file)
(mail-source-movemail file mail-source-crash-box))
- (incf found (mail-source-callback callback file))))
- (mail-source-run-script postscript (format-spec-make ?t path))
+ (incf found (mail-source-callback callback file))
+ (mail-source-run-script postscript (format-spec-make ?t path))
+ (mail-source-delete-crash-box)))
found)))
(defun mail-source-fetch-pop (source callback)
(mail-source-run-script
postscript
(format-spec-make ?p password ?t mail-source-crash-box
- ?s server ?P port ?u user))))
+ ?s server ?P port ?u user))
+ (mail-source-delete-crash-box)))
;; We nix out the password in case the error
;; was because of a wrong password being given.
(setq mail-source-password-cache
;; MMDF mail format
(insert "\001\001\001\001\n"))
(delete-file file)))))
- (incf found (mail-source-callback callback file))))))
+ (incf found (mail-source-callback callback file))
+ (mail-source-delete-crash-box)))))
found)))
(eval-and-compile
(goto-char (point-max))))
(nnheader-ms-strip-cr))
(incf found (mail-source-callback callback server))
+ (mail-source-delete-crash-box)
(when (and remove fetchflag)
(setq remove (nreverse remove))
(imap-message-flags-add
(push (cons (format "webmail:%s:%s" subtype user) password)
mail-source-password-cache)))
(webmail-fetch mail-source-crash-box subtype user password)
- (mail-source-callback callback (symbol-name subtype)))))
+ (mail-source-callback callback (symbol-name subtype))
+ (mail-source-delete-crash-box))))
(provide 'mail-source)
(defun nnrss-fetch (url &optional local)
"Fetch URL and put it in a the expected Lisp structure."
(with-temp-buffer
- ;some CVS versions of url.el need this to close the connection quickly
+ ;;some CVS versions of url.el need this to close the connection quickly
(let* (xmlform htmlform)
;; bit o' work necessary for w3 pre-cvs and post-cvs
(if local
(insert-file-contents url))
(mm-url-insert url))
-;; Because xml-parse-region can't deal with anything that isn't
-;; xml and w3-parse-buffer can't deal with some xml, we have to
-;; parse with xml-parse-region first and, if that fails, parse
-;; with w3-parse-buffer. Yuck. Eventually, someone should find out
-;; why w3-parse-buffer fails to parse some well-formed xml and
-;; fix it.
-
- (condition-case err
- (setq xmlform (xml-parse-region (point-min) (point-max)))
- (error (if (fboundp 'w3-parse-buffer)
- (setq htmlform (caddar (w3-parse-buffer
- (current-buffer))))
- (message "nnrss: Not valid XML and w3 parse not available (%s)"
- url))))
- (if htmlform
- htmlform
- xmlform))))
+ ;; Because xml-parse-region can't deal with anything that isn't
+ ;; xml and w3-parse-buffer can't deal with some xml, we have to
+ ;; parse with xml-parse-region first and, if that fails, parse
+ ;; with w3-parse-buffer. Yuck. Eventually, someone should find out
+ ;; why w3-parse-buffer fails to parse some well-formed xml and
+ ;; fix it.
+
+ (condition-case err
+ (setq xmlform (xml-parse-region (point-min) (point-max)))
+ (error (if (fboundp 'w3-parse-buffer)
+ (setq htmlform (caddar (w3-parse-buffer
+ (current-buffer))))
+ (message "nnrss: Not valid XML and w3 parse not available (%s)"
+ url))))
+ (if htmlform
+ htmlform
+ xmlform))))
(defun nnrss-possibly-change-group (&optional group server)
(when (and server
(unless (and spam-move-spam-nonspam-groups-only
(spam-group-spam-contents-p gnus-newsgroup-name))
- (gnus-message 6 "Marking spam as expired and moving it to %s"
- (gnus-parameter-spam-process-destination
- gnus-newsgroup-name))
- (spam-mark-spam-as-expired-and-move-routine
- (gnus-parameter-spam-process-destination gnus-newsgroup-name)))
+ (when (< 0 (length (spam-list-articles
+ gnus-newsgroup-articles
+ 'spam)))
+ (gnus-message 6 "Marking spam as expired and moving it to %s"
+ (gnus-parameter-spam-process-destination
+ gnus-newsgroup-name))
+ (spam-mark-spam-as-expired-and-move-routine
+ (gnus-parameter-spam-process-destination gnus-newsgroup-name))))
;; now we redo spam-mark-spam-as-expired-and-move-routine to only
;; expire spam, in case the above did not expire them
(spam-group-processor-p gnus-newsgroup-name processor))
(spam-register-routine classification check)))))
- (when (spam-group-ham-processor-copy-p gnus-newsgroup-name)
- (gnus-message 6 "Copying ham")
- (spam-ham-copy-routine
- (gnus-parameter-ham-process-destination gnus-newsgroup-name)))
-
- ;; now move all ham articles out of spam groups
- (when (spam-group-spam-contents-p gnus-newsgroup-name)
- (gnus-message 6 "Moving ham messages from spam group")
- (spam-ham-move-routine
- (gnus-parameter-ham-process-destination gnus-newsgroup-name))))
+ (when (< 0 (length (spam-list-articles
+ gnus-newsgroup-articles
+ 'ham)))
+ (when (spam-group-ham-processor-copy-p gnus-newsgroup-name)
+ (gnus-message 6 "Copying ham")
+ (spam-ham-copy-routine
+ (gnus-parameter-ham-process-destination gnus-newsgroup-name)))
+
+ ;; now move all ham articles out of spam groups
+ (when (spam-group-spam-contents-p gnus-newsgroup-name)
+ (gnus-message 6 "Moving ham messages from spam group")
+ (spam-ham-move-routine
+ (gnus-parameter-ham-process-destination gnus-newsgroup-name)))))
(setq spam-old-ham-articles nil)
(setq spam-old-spam-articles nil))