Remove duplicates from .newsrc list.
[gnus] / lisp / gnus-start.el
index b111f5c..0e35a12 100644 (file)
@@ -1747,18 +1747,19 @@ If SCAN, request a scan of that group as well."
            infos (nth 2 (car type-cache)))
       (pop type-cache)
 
-      ;; See if any of the groups from this method require updating.
-      (when (block nil
-             (dolist (info infos)
-               (when (<= (gnus-info-level info)
-                         (if (eq method-type 'foreign)
-                             foreign-level
-                           alevel))
-                 (return t))))
-       (gnus-read-active-for-groups method infos)
-       (dolist (info infos)
-         (inline (gnus-get-unread-articles-in-group
-                  info (gnus-active (gnus-info-group info)))))))
+      (when method
+       ;; See if any of the groups from this method require updating.
+       (when (block nil
+               (dolist (info infos)
+                 (when (<= (gnus-info-level info)
+                           (if (eq method-type 'foreign)
+                               foreign-level
+                             alevel))
+                   (return t))))
+         (gnus-read-active-for-groups method infos)
+         (dolist (info infos)
+           (inline (gnus-get-unread-articles-in-group
+                    info (gnus-active (gnus-info-group info))))))))
     (gnus-message 6 "Checking new news...done")))
 
 (defun gnus-method-rank (type method)
@@ -1814,14 +1815,18 @@ If SCAN, request a scan of that group as well."
        (if (setq rest (member method methods))
            (gnus-info-set-method info (car rest))
          (push method methods)))
-      (gnus-sethash
-       (car info)
-       ;; Preserve number of unread articles in groups.
-       (cons (and ohashtb (car (gnus-gethash (car info) ohashtb)))
-            prev)
-       gnus-newsrc-hashtb)
-      (setq prev alist
-           alist (cdr alist)))
+      ;; Check for duplicates.
+      (if (gnus-gethash (car info) gnus-newsrc-hashtb)
+         ;; Remove this entry from the alist.
+         (setcdr prev (cddr prev))
+       (gnus-sethash
+        (car info)
+        ;; Preserve number of unread articles in groups.
+        (cons (and ohashtb (car (gnus-gethash (car info) ohashtb)))
+              prev)
+        gnus-newsrc-hashtb)
+       (setq prev alist))
+      (setq alist (cdr alist)))
     ;; Make the same select-methods in `gnus-server-alist' identical
     ;; as well.
     (while methods