Skip to content

Commit 26b9434

Browse files
committed
Try different methods to compute sha1
It seems quicklisp and ultralisp differ how they compute sha1 sums
1 parent 1e8ad3f commit 26b9434

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

content-hash.lisp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ starting storage block in STREAM, and the total file size."
127127
until (= byte (char-code #\Newline))
128128
do (write-char (code-char byte) string))))
129129

130-
(defun content-hash (tarfile)
130+
(defun content-hash (tarfile &optional content-info-processor)
131131
"Return a hash string of TARFILE. The hash is computed by creating
132132
the digest of the files in TARFILE in order of their name."
133133
(uiop:with-temporary-file (:pathname temp)
@@ -150,7 +150,10 @@ the digest of the files in TARFILE in order of their name."
150150
(read-sequence buffer stream)
151151
(write-sequence buffer digest-stream :end partial))))
152152
(let ((contents (content-info stream)))
153-
(setf contents (sort contents #'string< :key #'first))
153+
(setf contents
154+
(if content-info-processor
155+
(funcall content-info-processor contents)
156+
contents))
154157
(dolist (info contents)
155158
(destructuring-bind (position size)
156159
(rest info)

ql-https.lisp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,15 @@
9595
"Checks that the md5 and size of FILE are as expected from the quicklisp
9696
dist."
9797
(let ((release (ql-dist:find-release name)))
98+
(unless (= (ql-dist:archive-size release) (file-size file))
99+
(error "file size mismatch for ~A" name))
98100
(unless (string-equal (ql-dist:archive-md5 release) (md5 file))
99101
(error "md5 mismatch for ~A" name))
100-
(unless (string-equal (ql-dist:archive-content-sha1 release) (content-hash file))
101-
(error "sha1 mismatch for ~A" name))
102-
(unless (= (ql-dist:archive-size release) (file-size file))
103-
(error "file size mismatch for ~A" name))))
102+
(unless (member (ql-dist:archive-content-sha1 release)
103+
(list (content-hash file (lambda (c) (sort c #'string< :key #'first)))
104+
(content-hash file #'reverse))
105+
:test #'string-equal)
106+
(error "sha1 mismatch for ~A" name))))
104107

105108
(defun register-fetch-scheme-functions ()
106109
(setf ql-http:*fetch-scheme-functions*

0 commit comments

Comments
 (0)