debugging type error with caching
This commit is contained in:
parent
af50388450
commit
1a872c52d0
|
@ -10,9 +10,13 @@
|
|||
racket/contract)
|
||||
|
||||
|
||||
(provide/contract
|
||||
[cached? (path? . -> . (or/c false/c bytes?))]
|
||||
[save-in-cache! (path? bytes? . -> . any)])
|
||||
(provide cached? save-in-cache!)
|
||||
|
||||
;; Contracts are off because when I dynamic-require, I can't
|
||||
;; dynamic require the syntaxes exposed by the contract.
|
||||
#;(provide/contract
|
||||
[cached? (path? . -> . (or/c false/c bytes?))]
|
||||
[save-in-cache! (path? bytes? . -> . any)])
|
||||
|
||||
|
||||
(define cache-directory-path
|
||||
|
|
|
@ -21,7 +21,30 @@
|
|||
(prefix-in query: "../lang/js/query.rkt")
|
||||
(prefix-in resource-query: "../resource/query.rkt")
|
||||
(prefix-in runtime: "get-runtime.rkt")
|
||||
(prefix-in racket: racket/base))
|
||||
(prefix-in racket: racket/base)
|
||||
racket/runtime-path)
|
||||
|
||||
|
||||
;; Here, I'm trying to dynamically require the db-cache module
|
||||
;; because not everyone's going to have Sqlite3 installed.
|
||||
;; If this fails, just gracefully fall back to no caching.
|
||||
(define-runtime-path db-cache.rkt "db-cache.rkt")
|
||||
(define-values (db-cache:cached? db-cache:save-in-cache!)
|
||||
(with-handlers ([exn:fail?
|
||||
(lambda (exn)
|
||||
(log-debug "Unable to use Sqlite3 cache. Falling back to no-cache.")
|
||||
(values (lambda (path)
|
||||
#f)
|
||||
(lambda (path data)
|
||||
(void))))])
|
||||
(parameterize ([current-namespace (make-base-namespace)])
|
||||
(values
|
||||
(dynamic-require `(file ,(path->string db-cache.rkt))
|
||||
'cached?)
|
||||
(dynamic-require `(file ,(path->string db-cache.rkt))
|
||||
'save-in-cache!)))))
|
||||
|
||||
|
||||
|
||||
;; There is a dynamic require for (planet dyoo/closure-compile) that's done
|
||||
;; if compression is turned on.
|
||||
|
@ -375,13 +398,16 @@ M.modules[~s] =
|
|||
;; Returns a true value (the cached bytes) if we've seen this path
|
||||
;; and know its JavaScript-compiled bytes.
|
||||
(define (cached? path)
|
||||
#f)
|
||||
(db-cache:cached? path))
|
||||
|
||||
|
||||
|
||||
;; cacheable?: path -> boolean
|
||||
;; Produces true if the file should be cached.
|
||||
;; At the current time, only cache modules that are provided
|
||||
;; by whalesong itself.
|
||||
(define (cacheable? path)
|
||||
#f)
|
||||
(within-whalesong-path? path))
|
||||
|
||||
|
||||
;; save-in-cache!: path bytes -> void
|
||||
|
@ -389,7 +415,8 @@ M.modules[~s] =
|
|||
;; TODO: Needs to sign with the internal version of Whalesong, and
|
||||
;; the md5sum of the path's content.
|
||||
(define (save-in-cache! path bytes)
|
||||
(void))
|
||||
(db-cache:save-in-cache! path bytes))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@
|
|||
begin-for-syntax
|
||||
prefix-in
|
||||
only-in
|
||||
rename-in
|
||||
provide
|
||||
planet
|
||||
all-defined-out
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
|
||||
|
||||
(provide/contract [rewrite-path (complete-path? . -> . (or/c symbol? false/c))])
|
||||
(provide/contract [rewrite-path (complete-path? . -> . (or/c symbol? false/c))]
|
||||
[within-whalesong-path? (complete-path? . -> . boolean?)])
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +32,7 @@
|
|||
(define (rewrite-path a-path)
|
||||
(let ([a-path (normalize-path a-path)])
|
||||
(cond
|
||||
[(within-this-project-path? a-path)
|
||||
[(within-whalesong-path? a-path)
|
||||
(string->symbol
|
||||
(string-append "whalesong/"
|
||||
(path->string
|
||||
|
@ -60,7 +61,7 @@
|
|||
(within? collects-path a-path))
|
||||
|
||||
|
||||
(define (within-this-project-path? a-path)
|
||||
(define (within-whalesong-path? a-path)
|
||||
(within? normal-whalesong-path a-path))
|
||||
|
||||
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
|
||||
(provide version)
|
||||
(: version String)
|
||||
(define version "1.10")
|
||||
(define version "1.19")
|
||||
|
|
Loading…
Reference in New Issue
Block a user