Skip to content

Commit 7fb66cb

Browse files
committed
cache namespace
This is a relatively easy fix, which means I leave the invalid cache not resolved. resolve #225 Signed-off-by: Lîm Tsú-thuàn <inbox@dannypsnl.me>
1 parent 162b11e commit 7fb66cb

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

collect/collector.rkt

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,15 @@
8484
#:requires requires))
8585
(super-new)))
8686

87-
(define (collect-from path)
87+
(define (collect-from path ns)
8888
(define text (new text%))
8989
(send text load-file path)
9090
(define collector (new collector% [src path] [text text]))
9191
(define-values (src-dir file dir?) (split-path path))
9292
(log:info "collect-from path: ~a" path)
9393
(define in (open-input-string (send text get-text)))
9494

95-
(try (define ns (make-base-namespace))
96-
(define-values (add-syntax done) (make-traversal ns src-dir))
95+
(try (define-values (add-syntax done) (make-traversal ns src-dir))
9796
(parameterize ([current-annotations collector]
9897
[current-namespace ns]
9998
[current-load-relative-directory src-dir])
@@ -125,4 +124,5 @@ modifier author: Lîm Tsú-thuàn(GitHub: @dannypsnl)
125124
(bytes->string/utf-8 v)))
126125

127126
(module+ main
128-
(record-doc (collect-from (normalize-path "collector.rkt"))))
127+
(define ns (make-base-namespace))
128+
(record-doc (collect-from (normalize-path "collector.rkt") ns)))

collect/record-maintainer.rkt

+3-2
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@
7171
(define (make-record-maintainer file-path)
7272
(thread
7373
(thunk
74-
(define cached-record (collect-from file-path))
74+
(define ns (make-base-namespace))
75+
(define cached-record (collect-from file-path ns))
7576
(let loop ()
7677
(match (thread-receive)
7778
[(list 'update)
7879
(match-define (struct* record ([created-time created-time])) cached-record)
7980
(when (< created-time (file-or-directory-modify-seconds file-path))
80-
(set! cached-record (collect-from file-path)))]
81+
(set! cached-record (collect-from file-path ns)))]
8182

8283
[(list 'require-location? from require)
8384
(define requires (record-requires cached-record))

0 commit comments

Comments
 (0)