* elmo-archive.el (elmo-folder-append-messages): Delete temp-dir
authoryoichi <yoichi>
Sun, 20 Aug 2006 15:30:32 +0000 (15:30 +0000)
committeryoichi <yoichi>
Sun, 20 Aug 2006 15:30:32 +0000 (15:30 +0000)
even if some error occurred.

elmo/ChangeLog
elmo/elmo-archive.el

index 4d4b96f..6ff3626 100644 (file)
@@ -1,5 +1,8 @@
 2006-08-20  Yoichi NAKAYAMA  <yoichi@geiin.org>
 
+       * elmo-archive.el (elmo-folder-append-messages): Delete temp-dir
+       even if some error occurred.
+
        * elmo-archive.el (elmo-archive-folder-append-buffer): Remove
        meaningless unwind-protect.
 
index c9387dd..80b8e61 100644 (file)
@@ -648,30 +648,32 @@ TYPE specifies the archiver's symbol."
                                                 folder))
                                 (car (elmo-folder-status folder)) 0)))))
            new-dir base-dir files)
-       (setq base-dir temp-dir)
-       (when (> (length prefix) 0)
-         (when (file-name-directory prefix)
-           (elmo-make-directory (file-name-directory prefix)))
-         (rename-file
-          temp-dir
-          (setq new-dir
-                (expand-file-name
-                 prefix
-                 ;; parent of temp-dir..(works in windows?)
-                 (expand-file-name ".." temp-dir))))
-         ;; now temp-dir has name prefix.
-         (setq temp-dir new-dir)
-         ;; parent of prefix becomes base-dir.
-         (setq base-dir (expand-file-name ".." temp-dir)))
-       (setq files
-             (mapcar
-              '(lambda (x) (elmo-concat-path prefix x))
-              (directory-files temp-dir nil "^[^\\.]")))
-       (if (elmo-archive-append-files folder
-                                      base-dir
-                                      files)
-           (elmo-delete-directory temp-dir)
-         (setq numbers nil)))
+       (unwind-protect
+           (progn
+             (setq base-dir temp-dir)
+             (when (> (length prefix) 0)
+               (when (file-name-directory prefix)
+                 (elmo-make-directory (file-name-directory prefix)))
+               (rename-file
+                temp-dir
+                (setq new-dir
+                      (expand-file-name
+                       prefix
+                       ;; parent of temp-dir..(works in windows?)
+                       (expand-file-name ".." temp-dir))))
+               ;; now temp-dir has name prefix.
+               (setq temp-dir new-dir)
+               ;; parent of prefix becomes base-dir.
+               (setq base-dir (expand-file-name ".." temp-dir)))
+             (setq files
+                   (mapcar
+                    '(lambda (x) (elmo-concat-path prefix x))
+                    (directory-files temp-dir nil "^[^\\.]")))
+             (unless (elmo-archive-append-files folder
+                                                base-dir
+                                                files)
+               (setq numbers nil)))
+         (elmo-delete-directory temp-dir)))
       (elmo-progress-notify 'elmo-folder-move-messages (length numbers))
       numbers)
      (t (luna-call-next-method)))))