[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/03: substitute-binary: Allow callers to specify the size of a narinfo
From: |
Ludovic Courtès |
Subject: |
02/03: substitute-binary: Allow callers to specify the size of a narinfo. |
Date: |
Mon, 05 Jan 2015 22:05:09 +0000 |
civodul pushed a commit to branch wip-http-pipelining
in repository guix.
commit fe2947e5d7537957db7c7c36c1df33152e03135f
Author: Ludovic Courtès <address@hidden>
Date: Mon Jan 5 22:31:34 2015 +0100
substitute-binary: Allow callers to specify the size of a narinfo.
* guix/scripts/substitute-binary.scm (read-narinfo): Add #:size
parameter and honor it.
---
guix/scripts/substitute-binary.scm | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/guix/scripts/substitute-binary.scm
b/guix/scripts/substitute-binary.scm
index 9c96411..7432bfa 100755
--- a/guix/scripts/substitute-binary.scm
+++ b/guix/scripts/substitute-binary.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014 Ludovic Courtès <address@hidden>
+;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <address@hidden>
;;; Copyright © 2014 Nikita Karetnikov <address@hidden>
;;;
;;; This file is part of GNU Guix.
@@ -300,12 +300,16 @@ NARINFO, doesn't match HASH, a bytevector containing the
hash of NARINFO."
(corrupt-signature
(leave (_ "signature on '~a' is corrupt~%") uri)))))
-(define* (read-narinfo port #:optional url)
+(define* (read-narinfo port #:optional url
+ #:key size)
"Read a narinfo from PORT. If URL is true, it must be a string used to
-build full URIs from relative URIs found while reading PORT.
+build full URIs from relative URIs found while reading PORT. When SIZE is
+true, read at most SIZE bytes from PORT; otherwise, read as much as possible.
No authentication and authorization checks are performed here!"
- (let ((str (utf8->string (get-bytevector-all port))))
+ (let ((str (utf8->string (if size
+ (get-bytevector-n port size)
+ (get-bytevector-all port)))))
(alist->record (call-with-input-string str fields->alist)
(narinfo-maker str url)
'("StorePath" "URL" "Compression"