@@ -92,6 +92,13 @@ starting storage block in STREAM, and the total file size."
9292 result))))
9393 (skip-n-octets-blocks size stream ))))))
9494
95+ (defun read-binary-line (stream )
96+ " Read a line from a binary stream and return it as an ascii string."
97+ (with-output-to-string (string )
98+ (loop for byte = (read-byte stream )
99+ until (= byte (char-code #\Newline ))
100+ do (write-char (code-char byte ) string ))))
101+
95102(defun content-hash (tarfile)
96103 " Return a hash string of TARFILE. The hash is computed by creating
97104the digest of the files in TARFILE in order of their name."
@@ -101,6 +108,7 @@ the digest of the files in TARFILE in order of their name."
101108 (with-open-file (stream tarfile :element-type ' (unsigned-byte 8 ))
102109 (let* ((openssl (uiop :launch-program " openssl dgst -sha1"
103110 :input :stream
111+ :element-type ' (unsigned-byte 8 )
104112 :output :stream ))
105113 (digest-stream (uiop :process-info-input openssl))
106114 (buffer (make-block-buffer)))
@@ -122,6 +130,6 @@ the digest of the files in TARFILE in order of their name."
122130 (close (uiop :process-info-input openssl))
123131 (unless (zerop (uiop :wait-process openssl))
124132 (error " openssl failed to calculate sha1" ))
125- (extract-openssl-digest (read-line (uiop :process-info-output openssl))))))
133+ (extract-openssl-digest (read-binary- line (uiop :process-info-output openssl))))))
126134 (when (probe-file temp)
127135 (ignore-errors (delete-file temp))))))
0 commit comments