From a42acbf2e670636bfcd92849e4e550aaed4f2fec Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 27 Aug 2015 22:41:20 -0700 Subject: [PATCH] use template source for hash key, not template output --- cache.rkt | 3 ++- file.rkt | 13 +++++++++++-- render.rkt | 9 --------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cache.rkt b/cache.rkt index 02c0ac2..3ae5833 100644 --- a/cache.rkt +++ b/cache.rkt @@ -72,7 +72,8 @@ (define (paths->key source-path [template-path #f]) ;; key is list of file + mod-time pairs, use #f for missing (define path-strings (append (list source-path) - (append (list template-path) ; is either path or #f + (append (list (and template-path (or (->source-path template-path) template-path))) ; if source-path exists, use that instead + (->list (get-directory-require-files source-path))))) ; is either list of files or (list #f) ;; can't use relative paths for cache keys because source files include `here-path` which is absolute. ;; problem is that cache could appear valid on another filesystem (based on relative pathnames & mod dates) diff --git a/file.rkt b/file.rkt index 46d5f88..d52e916 100644 --- a/file.rkt +++ b/file.rkt @@ -142,9 +142,18 @@ (values (->complete-path (or (get-stem-source path) (->stem-source-path path))) (->complete-path (->output-path path)))))))])) - (make-source-utility-functions preproc) +(define+provide/contract (->source+output-paths source-or-output-path) + (complete-path? . -> . (values complete-path? complete-path?)) + ;; file-proc returns two values, but ormap only wants one + (define file-proc (ormap (λ(test file-proc) (and (test source-or-output-path) file-proc)) + (list has/is-null-source? has/is-preproc-source? has/is-markup-source? has/is-scribble-source? has/is-markdown-source? has/is-template-source?) + (list ->null-source+output-paths ->preproc-source+output-paths ->markup-source+output-paths ->scribble-source+output-paths ->markdown-source+output-paths ->template-source+output-paths))) + (file-proc source-or-output-path)) + + + (module-test-external (require sugar/coerce) (check-true (preproc-source? "foo.pp")) @@ -242,7 +251,7 @@ (define+provide (cache-file? path) (ormap (λ(cache-name) (ends-with? (path->string path) cache-name)) world:cache-names)) -(require sugar/debug) + (define+provide (pollen-related-file? file) (ormap (λ(proc) (proc file)) (list preproc-source? diff --git a/render.rkt b/render.rkt index 206fccb..13f7067 100644 --- a/render.rkt +++ b/render.rkt @@ -90,15 +90,6 @@ (void)) -(define/contract (->source+output-paths source-or-output-path) - (complete-path? . -> . (values complete-path? complete-path?)) - ;; file-proc returns two values, but ormap only wants one - (define file-proc (ormap (λ(test file-proc) (and (test source-or-output-path) file-proc)) - (list has/is-null-source? has/is-preproc-source? has/is-markup-source? has/is-scribble-source? has/is-markdown-source? has/is-template-source?) - (list ->null-source+output-paths ->preproc-source+output-paths ->markup-source+output-paths ->scribble-source+output-paths ->markdown-source+output-paths ->template-source+output-paths))) - (file-proc source-or-output-path)) - - (define/contract (render-needed? source-path template-path output-path) (complete-path? (or/c #f complete-path?) complete-path? . -> . (or/c #f symbol?)) ;; return symbol rather than boolean for extra debugging information