* nnfolder.el (nnfolder-request-group, nnfolder-request-create-group): Check if
authorKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 10 May 2007 10:22:26 +0000 (10:22 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 10 May 2007 10:22:26 +0000 (10:22 +0000)
 group is not a directory.
(nnfolder-request-expire-articles): Don't delete articles if the target group is
 not available.

* nnml.el (nnml-request-create-group): Properly check if group is not a file.
(nnml-request-expire-articles): Don't delete articles if the target group is not
 available.

lisp/ChangeLog
lisp/nnfolder.el
lisp/nnml.el

index e91c666..90f5bb9 100644 (file)
@@ -1,5 +1,15 @@
 2007-05-10  Katsumi Yamaoka  <yamaoka@jpl.org>
 
+       * nnfolder.el (nnfolder-request-group, nnfolder-request-create-group):
+       Check if group is not a directory.
+       (nnfolder-request-expire-articles): Don't delete articles if the target
+       group is not available.
+
+       * nnml.el (nnml-request-create-group): Properly check if group is not a
+       file.
+       (nnml-request-expire-articles): Don't delete articles if the target
+       group is not available.
+
        * rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings):
        Don't quote characters that are within parentheses.
 
index 752e2b0..c00def9 100644 (file)
@@ -293,25 +293,30 @@ the group.  Then the marks file will be regenerated properly by Gnus.")
 (deffoo nnfolder-request-group (group &optional server dont-check)
   (nnfolder-possibly-change-group group server t)
   (save-excursion
-    (if (not (assoc group nnfolder-group-alist))
-       (nnheader-report 'nnfolder "No such group: %s" group)
-      (if dont-check
-         (progn
-           (nnheader-report 'nnfolder "Selected group %s" group)
-           t)
-       (let* ((active (assoc group nnfolder-group-alist))
-              (group (car active))
-              (range (cadr active)))
-         (cond
-          ((null active)
-           (nnheader-report 'nnfolder "No such group: %s" group))
-          ((null nnfolder-current-group)
-           (nnheader-report 'nnfolder "Empty group: %s" group))
-          (t
-           (nnheader-report 'nnfolder "Selected group %s" group)
-           (nnheader-insert "211 %d %d %d %s\n"
-                            (1+ (- (cdr range) (car range)))
-                            (car range) (cdr range) group))))))))
+    (cond ((not (assoc group nnfolder-group-alist))
+          (nnheader-report 'nnfolder "No such group: %s" group))
+         ((file-directory-p (nnfolder-group-pathname group))
+          (nnheader-report 'nnfolder "%s is a directory"
+                           (file-name-as-directory
+                            (let ((nnmail-pathname-coding-system nil))
+                              (nnfolder-group-pathname group)))))
+         (dont-check
+          (nnheader-report 'nnfolder "Selected group %s" group)
+          t)
+         (t
+          (let* ((active (assoc group nnfolder-group-alist))
+                 (group (car active))
+                 (range (cadr active)))
+            (cond
+             ((null active)
+              (nnheader-report 'nnfolder "No such group: %s" group))
+             ((null nnfolder-current-group)
+              (nnheader-report 'nnfolder "Empty group: %s" group))
+             (t
+              (nnheader-report 'nnfolder "Selected group %s" group)
+              (nnheader-insert "211 %d %d %d %s\n"
+                               (1+ (- (cdr range) (car range)))
+                               (car range) (cdr range) group))))))))
 
 (deffoo nnfolder-request-scan (&optional group server)
   (nnfolder-possibly-change-group nil server)
@@ -371,13 +376,21 @@ the group.  Then the marks file will be regenerated properly by Gnus.")
 (deffoo nnfolder-request-create-group (group &optional server args)
   (nnfolder-possibly-change-group nil server)
   (nnmail-activate 'nnfolder)
-  (when (and group
-            (not (assoc group nnfolder-group-alist)))
-    (push (list group (cons 1 0)) nnfolder-group-alist)
-    (nnfolder-save-active nnfolder-group-alist nnfolder-active-file)
-    (save-current-buffer
-      (nnfolder-read-folder group)))
-  t)
+  (cond ((zerop (length group))
+        (nnheader-report 'nnfolder "Invalid (empty) group name"))
+       ((file-directory-p (nnfolder-group-pathname group))
+        (nnheader-report 'nnfolder "%s is a directory"
+                         (file-name-as-directory
+                          (let ((nnmail-pathname-coding-system nil))
+                            (nnfolder-group-pathname group)))))
+       ((assoc group nnfolder-group-alist)
+        t)
+       (t
+        (push (list group (cons 1 0)) nnfolder-group-alist)
+        (nnfolder-save-active nnfolder-group-alist nnfolder-active-file)
+        (save-current-buffer
+          (nnfolder-read-folder group))
+        t)))
 
 (deffoo nnfolder-request-list (&optional server)
   (nnfolder-possibly-change-group nil server)
@@ -416,16 +429,17 @@ the group.  Then the marks file will be regenerated properly by Gnus.")
       ;; The article numbers are increasing, so this result is sorted.
        (nreverse numbers)))))
 
-(deffoo nnfolder-request-expire-articles
-    (articles newsgroup &optional server force)
+(deffoo nnfolder-request-expire-articles (articles newsgroup
+                                                  &optional server force)
   (nnfolder-possibly-change-group newsgroup server)
-  (let* ((is-old t)
-        ;; The articles we have deleted so far.
-        (deleted-articles nil)
-        ;; The articles that really exist and will
-        ;; be expired if they are old enough.
-        (maybe-expirable
-         (gnus-sorted-intersection articles (nnfolder-existing-articles))))
+  (let ((is-old t)
+       ;; The articles we have deleted so far.
+       (deleted-articles nil)
+       ;; The articles that really exist and will
+       ;; be expired if they are old enough.
+       (maybe-expirable
+        (gnus-sorted-intersection articles (nnfolder-existing-articles)))
+       target)
     (nnmail-activate 'nnfolder)
 
     (save-excursion
@@ -445,21 +459,28 @@ the group.  Then the marks file will be regenerated properly by Gnus.")
                       (buffer-substring
                        (point) (progn (end-of-line) (point)))
                       force nnfolder-inhibit-expiry))
-           (unless (eq nnmail-expiry-target 'delete)
+           (setq target nnmail-expiry-target)
+           (unless (eq target 'delete)
              (with-temp-buffer
                (nnfolder-request-article (car maybe-expirable)
                                          newsgroup server (current-buffer))
                (let ((nnfolder-current-directory nil))
-                 (nnmail-expiry-target-group
-                  nnmail-expiry-target newsgroup)))
+                 (when (functionp target)
+                   (setq target (funcall target newsgroup)))
+                 (if (and target
+                          (or (gnus-request-group target)
+                              (gnus-request-create-group target)))
+                     (nnmail-expiry-target-group target newsgroup)
+                   (setq target nil))))
              (nnfolder-possibly-change-group newsgroup server))
-           (nnheader-message 5 "Deleting article %d in %s..."
-                             (car maybe-expirable) newsgroup)
-           (nnfolder-delete-mail)
-           (unless (or gnus-nov-is-evil nnfolder-nov-is-evil)
-             (nnfolder-nov-delete-article newsgroup (car maybe-expirable)))
-           ;; Must remember which articles were actually deleted
-           (push (car maybe-expirable) deleted-articles)))
+           (when target
+             (nnheader-message 5 "Deleting article %d in %s..."
+                               (car maybe-expirable) newsgroup)
+             (nnfolder-delete-mail)
+             (unless (or gnus-nov-is-evil nnfolder-nov-is-evil)
+               (nnfolder-nov-delete-article newsgroup (car maybe-expirable)))
+             ;; Must remember which articles were actually deleted
+             (push (car maybe-expirable) deleted-articles))))
        (setq maybe-expirable (cdr maybe-expirable)))
       (unless nnfolder-inhibit-expiry
        (nnheader-message 5 "Deleting articles...done"))
index f9ff8f6..08610c1 100644 (file)
@@ -265,12 +265,16 @@ non-nil.")
   (nnml-possibly-change-directory nil server)
   (nnmail-activate 'nnml)
   (cond
+   ((let ((file (directory-file-name
+                (nnmail-group-pathname group nnml-directory))))
+      (and (file-exists-p file)
+          (not (file-directory-p file))))
+    (nnheader-report 'nnml "%s is a file"
+                    (directory-file-name
+                     (let ((nnmail-pathname-coding-system nil))
+                       (nnmail-group-pathname group nnml-directory)))))
    ((assoc group nnml-group-alist)
     t)
-   ((and (file-exists-p (nnmail-group-pathname group nnml-directory))
-        (not (file-directory-p (nnmail-group-pathname group nnml-directory))))
-    (nnheader-report 'nnml "%s is a file"
-                    (nnmail-group-pathname group nnml-directory)))
    (t
     (let (active)
       (push (list group (setq active (cons 1 0)))
@@ -304,7 +308,7 @@ non-nil.")
   (let ((active-articles
         (nnml-directory-articles nnml-current-directory))
        (is-old t)
-       article rest mod-time number)
+       article rest mod-time number target)
     (nnmail-activate 'nnml)
 
     (setq active-articles (sort active-articles '<))
@@ -321,23 +325,33 @@ non-nil.")
                                                      nnml-inhibit-expiry)))
          (progn
            ;; Allow a special target group.
-           (unless (eq nnmail-expiry-target 'delete)
+           (setq target nnmail-expiry-target)
+           (unless (eq target 'delete)
              (with-temp-buffer
                (nnml-request-article number group server (current-buffer))
                (let (nnml-current-directory
                      nnml-current-group
                      nnml-article-file-alist)
-                 (nnmail-expiry-target-group nnmail-expiry-target group)))
+                 (when (functionp target)
+                   (setq target (funcall target group)))
+                 (if (and target
+                          (or (gnus-request-group target)
+                              (gnus-request-create-group target)))
+                     (nnmail-expiry-target-group target group)
+                   (setq target nil))))
              ;; Maybe directory is changed during nnmail-expiry-target-group.
              (nnml-possibly-change-directory group server))
-           (nnheader-message 5 "Deleting article %s in %s"
-                             number group)
-           (condition-case ()
-               (funcall nnmail-delete-file-function article)
-             (file-error
-              (push number rest)))
-           (setq active-articles (delq number active-articles))
-           (nnml-nov-delete-article group number))
+           (if target
+               (progn
+                 (nnheader-message 5 "Deleting article %s in %s"
+                                   number group)
+                 (condition-case ()
+                     (funcall nnmail-delete-file-function article)
+                   (file-error
+                    (push number rest)))
+                 (setq active-articles (delq number active-articles))
+                 (nnml-nov-delete-article group number))
+             (push number rest)))
        (push number rest)))
     (let ((active (nth 1 (assoc group nnml-group-alist))))
       (when active