Explorar el Código

Factor purge-all calls in discover to a before method.

Brit Butler hace 11 años
padre
commit
c17bcdd385
Se han modificado 2 ficheros con 3 adiciones y 4 borrados
  1. 3 1
      src/documents.lisp
  2. 0 3
      src/indexes.lisp

+ 3 - 1
src/documents.lisp

@@ -34,11 +34,13 @@
34 34
   (:method (doc-type)
35 35
     (let* ((class-name (class-name doc-type))
36 36
            (file-type (string-downcase (symbol-name class-name))))
37
-      (purge-all class-name)
38 37
       (do-files (file (repo *config*) file-type)
39 38
         (let ((obj (construct class-name (read-content file))))
40 39
           (add-document obj))))))
41 40
 
41
+(defmethod discover :before (doc-type)
42
+  (purge-all (class-name doc-type)))
43
+
42 44
 ;; Instance Methods
43 45
 
44 46
 (defgeneric page-url (document)

+ 0 - 3
src/indexes.lisp

@@ -21,7 +21,6 @@
21 21
   (format nil "tag/~a" (index-slug object)))
22 22
 
23 23
 (defmethod discover ((doc-type (eql (find-class 'tag-index))))
24
-  (purge-all (class-name doc-type))
25 24
   (let ((content (by-date (find-all 'post))))
26 25
     (dolist (tag (all-tags))
27 26
       (add-document (index-by-tag tag content)))))
@@ -44,7 +43,6 @@
44 43
   (format nil "date/~a" (index-slug object)))
45 44
 
46 45
 (defmethod discover ((doc-type (eql (find-class 'month-index))))
47
-  (purge-all (class-name doc-type))
48 46
   (let ((content (by-date (find-all 'post))))
49 47
     (dolist (month (all-months))
50 48
       (add-document (index-by-month month content)))))
@@ -67,7 +65,6 @@
67 65
   (format nil "~d" (index-slug object)))
68 66
 
69 67
 (defmethod discover ((doc-type (eql (find-class 'numeric-index))))
70
-  (purge-all (class-name doc-type))
71 68
   (let ((content (by-date (find-all 'post))))
72 69
     (dotimes (i (ceiling (length content) 10))
73 70
       (add-document (index-by-n i content)))))