1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:24:41 -07:00

godoc/dl: record and display SHA256 hashes for files

Fixes golang/go#12057

Change-Id: I2e0a27c96f3f13478a079765b8c363c9f3919c48
Reviewed-on: https://go-review.googlesource.com/18354
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Andrew Gerrand 2016-01-07 15:16:41 +11:00
parent 1e63c6ac3b
commit 819a9109e1
2 changed files with 29 additions and 13 deletions

View File

@ -53,12 +53,27 @@ type File struct {
OS string
Arch string
Version string
Checksum string `datastore:",noindex"`
Checksum string `datastore:",noindex"` // SHA1; deprecated
ChecksumSHA256 string `datastore:",noindex"`
Size int64 `datastore:",noindex"`
Kind string // "archive", "installer", "source"
Uploaded time.Time
}
func (f File) ChecksumType() string {
if f.ChecksumSHA256 != "" {
return "SHA256"
}
return "SHA1"
}
func (f File) PrettyChecksum() string {
if f.ChecksumSHA256 != "" {
return f.ChecksumSHA256
}
return f.Checksum
}
func (f File) PrettyOS() string {
if f.OS == "darwin" {
switch {

View File

@ -33,7 +33,7 @@ const templateHTML = `
padding: 6px 10px;
}
table.codetable tt {
font-size: x-small;
font-size: xx-small;
}
table.codetable tr.highlight td {
font-weight: bold;
@ -73,7 +73,7 @@ const templateHTML = `
font-style: italic;
}
.downloadBox .checksum {
font-size: x-small;
font-size: 5pt;
}
</style>
</head>
@ -235,7 +235,8 @@ $(document).ready(function() {
<th>OS</th>
<th>Arch</th>
<th>Size</th>
<th>SHA1 Checksum</th>
{{/* Use the checksum type of the first file for the column heading. */}}
<th>{{(index . 0).ChecksumType}} Checksum</th>
</tr>
</thead>
{{range .}}
@ -245,7 +246,7 @@ $(document).ready(function() {
<td>{{.PrettyOS}}</td>
<td>{{pretty .Arch}}</td>
<td>{{.PrettySize}}</td>
<td><tt>{{.Checksum}}</tt></td>
<td><tt>{{.PrettyChecksum}}</tt></td>
</tr>
{{else}}
<tr>
@ -263,7 +264,7 @@ $(document).ready(function() {
<span class="filename">{{.Filename}}</span>
{{if .Size}}<span class="size">({{.PrettySize}})</span>{{end}}
</div>
<div class="checksum">SHA1: {{.Checksum}}</div>
<div class="checksum">{{.ChecksumType}}: {{.PrettyChecksum}}</div>
</a>
{{end}}
`