guix hash: Don't load the whole file in memory.

* guix/scripts/hash.scm (guix-hash)[eof->null]: Remove.
  (guix-hash): Use 'port-sha256' to compute the hash instead of
  'get-bytevector-all' and co.
master
Ludovic Courtès 2014-02-20 12:25:14 +01:00
parent 62d4575de2
commit c6d37be951
1 changed files with 2 additions and 8 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -99,11 +99,6 @@ Supported formats: 'nix-base32' (default), 'base32', and 'base16'
(alist-cons 'argument arg result)) (alist-cons 'argument arg result))
%default-options)) %default-options))
(define (eof->null x)
(if (eof-object? x)
#vu8()
x))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda
(('argument . value) (('argument . value)
@ -117,8 +112,7 @@ Supported formats: 'nix-base32' (default), 'base32', and 'base16'
(catch 'system-error (catch 'system-error
(lambda () (lambda ()
(format #t "~a~%" (format #t "~a~%"
(call-with-input-file file (fmt (call-with-input-file file port-sha256))))
(compose fmt sha256 eof->null get-bytevector-all))))
(lambda args (lambda args
(leave (_ "~a~%") (leave (_ "~a~%")
(strerror (system-error-errno args)))))) (strerror (system-error-errno args))))))