fix ambiguous cache keys

pull/84/head
Matthew Butterick 9 years ago
parent 024db31a63
commit 0b092f87cb

@ -15,23 +15,23 @@
(cache-remove #f cache-dir)) (cache-remove #f cache-dir))
(define (paths->key source-path [template-path #f]) (define (paths->key source-path [template-path #f] #:subkey [subkey #f])
;; key is list of file + mod-time pairs ;; key is list of file + mod-time pairs, use #f for missing
(define path-strings (append (list source-path) (define path-strings (append (list source-path)
(if template-path (list template-path) null) (if (eq? subkey (world:current-meta-export))
(or (get-directory-require-files source-path) null))) null ; metas only depend on source-path
(define project-root (world:current-project-root)) (append (list template-path) ; is either path or #f
(->list (get-directory-require-files source-path))))))
;; can't use relative paths for cache keys because source files include `here-path` which is absolute. ;; 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) ;; problem is that cache could appear valid on another filesystem (based on relative pathnames & mod dates)
;; but would actually be invalid (because the `here-path` names are wrong). ;; but would actually be invalid (because the `here-path` names are wrong).
(map (λ(ps) (define cp (->complete-path ps)) (define path+mod-time-pairs
(cons (path->string cp) (file-or-directory-modify-seconds cp))) path-strings)) (map (λ(ps) (and ps (let ([cp (->complete-path ps)])
(cons (path->string cp) (file-or-directory-modify-seconds cp))))) path-strings))
(define (key->source-path-key key) (cons subkey path+mod-time-pairs))
(list (car key)))
(define (key->source-path key) (define (key->source-path key)
(car (car key))) (car (cadr key)))
(define (update-directory-requires source-path) (define (update-directory-requires source-path)
(define directory-require-files (get-directory-require-files source-path)) (define directory-require-files (get-directory-require-files source-path))
@ -78,10 +78,7 @@
(cond (cond
[(world:current-compile-cache-active) [(world:current-compile-cache-active)
(define key (let ([possible-key (paths->key path)]) (define key (paths->key path #:subkey subkey))
(if (eq? subkey (world:current-meta-export))
(key->source-path-key possible-key)
possible-key)))
;; use multiple pickup files to avoid locking issues. ;; use multiple pickup files to avoid locking issues.
;; pickup-file hierarchy just mirrors the project hierarchy. ;; pickup-file hierarchy just mirrors the project hierarchy.
(define dest-file (build-path cache-dir (path->string (find-relative-path (world:current-project-root) (string->path (format "~a#~a.rktd" (key->source-path key) subkey)))))) (define dest-file (build-path cache-dir (path->string (find-relative-path (world:current-project-root) (string->path (format "~a#~a.rktd" (key->source-path key) subkey))))))

Loading…
Cancel
Save