Use temp directory
This commit is contained in:
parent
05298fb1f0
commit
93c7ef8046
|
@ -7,6 +7,7 @@
|
|||
(scheme write)
|
||||
(only (chicken blob) blob->string)
|
||||
(only (chicken file) create-temporary-directory)
|
||||
(chicken process-context)
|
||||
(chicken process)
|
||||
(only (srfi 4) u8vector->blob)
|
||||
(spiffy)
|
||||
|
@ -68,6 +69,12 @@
|
|||
(make-tar-header-for-regular-file filename bytes)
|
||||
bytes (make-tar-padding bytes)))
|
||||
|
||||
(define (with-current-directory dir proc)
|
||||
(let ((old-dir (current-directory)))
|
||||
(dynamic-wind (lambda () (change-directory dir))
|
||||
proc
|
||||
(lambda () (change-directory old-dir)))))
|
||||
|
||||
(define (handle-the-scheme-implementation impl)
|
||||
(let ((cmdline #f)
|
||||
(environ #f)
|
||||
|
@ -115,13 +122,16 @@
|
|||
(error "No main.scm file in archive"))
|
||||
(let ((tempdir (create-temporary-directory)))
|
||||
(write tempdir)(newline)
|
||||
(with-current-directory
|
||||
tempdir
|
||||
(lambda ()
|
||||
(for-each (lambda (entry)
|
||||
(let ((name (car entry))
|
||||
(bytes (cdr entry)))
|
||||
(call-with-port
|
||||
(open-binary-output-file name)
|
||||
(lambda (out) (write-bytevector bytes out)))))
|
||||
files))
|
||||
files)
|
||||
(let ((command (append (implementation-command-line impl)
|
||||
(list "main.scm")
|
||||
cmdline)))
|
||||
|
@ -131,7 +141,7 @@
|
|||
(write-bytevector stdin to-sub)
|
||||
(close-output-port to-sub)
|
||||
(set! stdout (read-all-bytes from-sub))
|
||||
(set! stderr (read-all-bytes from-sub-err))))
|
||||
(set! stderr (read-all-bytes from-sub-err)))))))
|
||||
(send-response
|
||||
status: 'ok
|
||||
headers: `((content-type ,tar-content-type))
|
||||
|
|
Loading…
Reference in New Issue