* elmo-map.el (elmo-folder-pack-numbers): Rewrite.
authorhmurata <hmurata>
Sat, 6 Sep 2003 14:12:01 +0000 (14:12 +0000)
committerhmurata <hmurata>
Sat, 6 Sep 2003 14:12:01 +0000 (14:12 +0000)
* elmo-localdir.el (elmo-folder-pack-numbers): Fixed last chagne.

* elmo-msgdb.el (elmo-msgdb-append-entity): Fixed.

elmo/ChangeLog
elmo/elmo-localdir.el
elmo/elmo-map.el
elmo/elmo-msgdb.el

index b593fbe..d869f8e 100644 (file)
@@ -1,5 +1,11 @@
 2003-09-06  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
+       * elmo-map.el (elmo-folder-pack-numbers): Rewrite.
+
+       * elmo-localdir.el (elmo-folder-pack-numbers): Fixed last chagne.
+
+       * elmo-msgdb.el (elmo-msgdb-append-entity): Fixed.
+
        * elmo-util.el (elmo-with-progress-display): New macro.
 
        * elmo-localdir.el (elmo-folder-pack-numbers): Rewrite.
index e128a3f..5e8d96c 100644 (file)
   (let* ((dir (elmo-localdir-folder-directory-internal folder))
         (msgdb (elmo-folder-msgdb folder))
         (new-msgdb (elmo-make-msgdb))
-        (numbers (elmo-folder-list-messages
-                  folder
-                  (not elmo-pack-number-check-strict)))
+        (numbers (sort (elmo-folder-list-messages
+                        folder
+                        (not elmo-pack-number-check-strict))
+                       '<))
         (new-number 1)           ; first ordinal position in localdir
         total entity)
     (elmo-msgdb-set-path new-msgdb (elmo-folder-msgdb-path folder))
index 2657ea5..4d422a6 100644 (file)
 
 (luna-define-method elmo-folder-pack-numbers ((folder elmo-map-folder))
   (let* ((msgdb (elmo-folder-msgdb folder))
-        (old-number-alist (elmo-msgdb-get-number-alist msgdb))
-        (old-overview (elmo-msgdb-get-overview msgdb))
-        (old-mark-alist (elmo-msgdb-get-mark-alist msgdb))
-        (old-location (elmo-map-folder-location-alist-internal folder))
-        old-number overview number-alist mark-alist location
-        mark (number 1))
-    (setq overview old-overview)
-    (while old-overview
-      (setq old-number
-           (elmo-msgdb-overview-entity-get-number (car old-overview)))
-      (elmo-msgdb-overview-entity-set-number (car old-overview) number)
-      (setq number-alist
-           (cons (cons number (cdr (assq old-number old-number-alist)))
-                 number-alist))
-      (when (setq mark (cadr (assq old-number old-mark-alist)))
-       (setq mark-alist
-             (elmo-msgdb-mark-append
-              mark-alist number mark)))
-      (setq location
-           (cons (cons number
-                       (elmo-map-message-location folder old-number))
-                 location))
-      (setq number (1+ number))
-      (setq old-overview (cdr old-overview)))
+        (numbers (sort (elmo-folder-list-messages folder 'in-db) '<))
+        (new-msgdb (elmo-make-msgdb))
+        (number 1)
+        total location entity)
+    (elmo-msgdb-set-path new-msgdb (elmo-folder-msgdb-path folder))
+    (setq total (length numbers))
+    (elmo-with-progress-display (> total elmo-display-progress-threshold)
+       (elmo-folder-pack-numbers total "Packing...")
+      (dolist (old-number numbers)
+       (setq entity (elmo-msgdb-message-entity msgdb old-number))
+       (elmo-msgdb-overview-entity-set-number entity number)
+       (elmo-msgdb-append-entity new-msgdb entity
+                                 (elmo-msgdb-get-mark msgdb old-number))
+       (setq location
+             (cons (cons number
+                         (elmo-map-message-location folder old-number))
+                   location))
+       (setq number (1+ number))))
+    (message "Packing...done")
     (elmo-map-folder-location-setup folder (nreverse location))
-    (elmo-folder-set-msgdb-internal
-     folder
-     (elmo-make-msgdb overview
-                     (nreverse number-alist)
-                     (nreverse mark-alist)))))
+    (elmo-folder-set-msgdb-internal folder new-msgdb)))
 
 (defun elmo-map-folder-location-setup (folder locations)
   (elmo-map-folder-set-location-alist-internal
index fc66b2b..4ea7e10 100644 (file)
@@ -416,7 +416,7 @@ FLAG is a symbol which is one of the following:
       (elmo-msgdb-make-index
        msgdb
        (list entity)
-       (list (cons number mark))))))
+       (list (list number mark))))))
 
 (defsubst elmo-msgdb-get-number (msgdb message-id)
   "Get number of the message which corrensponds to MESSAGE-ID from MSGDB."