(zilch lang go vfs): fix directories not making it to the store

Sadly, iterating twice won't work, as this will create directory
associations in the wrong direction, and there's no way mappings
let you iterate backwards. Let's mark the entries as directories
and then swap them out with the directories when building a zdir
tree instead.
This commit is contained in:
puck 2024-11-16 16:41:56 +00:00
parent fc8aea8fb4
commit fe53998fcc
2 changed files with 12 additions and 13 deletions

View file

@ -104,20 +104,19 @@
(lambda (k contents)
(define dir (car k))
(define fname (cdr k))
(unless (eq? contents 'directory)
(if (eq? contents 'directory)
(set! dirmap (mapping-update!/default dirmap dir (lambda (v) (cons (cons fname 'directory) v)) '()))
(set! dirmap (mapping-update!/default dirmap dir (lambda (v) (cons (cons fname (zsymlink contents)) v)) '()))))
(vfs-contents vfs))
(mapping-for-each
(lambda (k contents)
(define dir (car k))
(define fname (cdr k))
(when (eq? contents 'directory)
(let*
((name (string-append dir "/" fname))
(dir (mapping-ref dirmap name)))
(set! dirmap (mapping-update!/default dirmap dir (lambda (v) (cons (cons fname (zdir dir)) v)) '())))))
(vfs-contents vfs))
(zdir (mapping-ref/default dirmap "" '())))
(define (read-dir dirname)
(define contents (mapping-ref dirmap dirname))
(for-each
(lambda (pair)
(when (eq? (cdr pair) 'directory)
(set-cdr! pair (read-dir (if (string=? dirname "") (car pair) (string-append dirname "/" (car pair)))))))
contents)
(zdir contents))
(read-dir ""))
;; Reads a dirhash from a `go.sum` line. This prefetches the module from
;; the go module proxy, and then generates the dirhash without unpacking