nar: Fix file descriptor leak when writing a Nar.

* guix/nar.scm (write-contents)[call-with-binary-input-file]: Always
  close PORT.
This commit is contained in:
Ludovic Courtès 2013-09-22 22:13:51 +02:00
parent f566d765a1
commit 48e488eb2c

View file

@ -76,10 +76,11 @@ (define (call-with-binary-input-file file proc)
;; avoid stat'ing like crazy.
(with-fluids ((%file-port-name-canonicalization #f))
(let ((port (open-file file "rb")))
(catch #t (cut proc port)
(lambda args
(close-port port)
(apply throw args))))))
(dynamic-wind
(const #t)
(cut proc port)
(lambda ()
(close-port port))))))
(write-string "contents" p)
(write-long-long size p)