Index: crystalize.rkt ================================================================== --- crystalize.rkt +++ crystalize.rkt @@ -98,10 +98,23 @@ (define (init-cache-db!) (create-table! cache-conn 'cache:article) (create-table! cache-conn 'cache:note) (create-table! cache-conn 'cache:series) (create-table! cache-conn 'cache:index-entry)) + +(define (delete-article! page) + (query-exec cache-conn + (~> (from cache:article #:as a) + (where (= a.page ,(format "~a" page))) + delete))) + +(define (delete-notes! page) + (query-exec cache-conn + (~> (from cache:note #:as n) + (where (= n.page ,(format "~a" page))) + delete))) + ;; Save an article and its notes (if any) to the database, and return the ;; rendered HTML of the complete article. ;; (define (parse-and-cache-article! pagenode doc) @@ -129,10 +142,11 @@ [footer (html$-article-close footertext)] [listing-short (html$-article-listing-short pagenode pubdate title-html)] [notes-section-html (cache-notes! pagenode title-plain note-txprs)]) (cache-index-entries! pagenode doc) ; note original doc is used here (current-plain-title title-plain) + (delete-article! pagenode) (insert-one! cache-conn (make-cache:article #:page pagenode #:title-plain title-plain #:title-html-flow title-html