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:
parent
1e63c6ac3b
commit
819a9109e1
|
@ -49,14 +49,29 @@ func RegisterHandlers(mux *http.ServeMux) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
Filename string
|
Filename string
|
||||||
OS string
|
OS string
|
||||||
Arch string
|
Arch string
|
||||||
Version string
|
Version string
|
||||||
Checksum string `datastore:",noindex"`
|
Checksum string `datastore:",noindex"` // SHA1; deprecated
|
||||||
Size int64 `datastore:",noindex"`
|
ChecksumSHA256 string `datastore:",noindex"`
|
||||||
Kind string // "archive", "installer", "source"
|
Size int64 `datastore:",noindex"`
|
||||||
Uploaded time.Time
|
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 {
|
func (f File) PrettyOS() string {
|
||||||
|
|
|
@ -33,7 +33,7 @@ const templateHTML = `
|
||||||
padding: 6px 10px;
|
padding: 6px 10px;
|
||||||
}
|
}
|
||||||
table.codetable tt {
|
table.codetable tt {
|
||||||
font-size: x-small;
|
font-size: xx-small;
|
||||||
}
|
}
|
||||||
table.codetable tr.highlight td {
|
table.codetable tr.highlight td {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -73,7 +73,7 @@ const templateHTML = `
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
.downloadBox .checksum {
|
.downloadBox .checksum {
|
||||||
font-size: x-small;
|
font-size: 5pt;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
@ -235,7 +235,8 @@ $(document).ready(function() {
|
||||||
<th>OS</th>
|
<th>OS</th>
|
||||||
<th>Arch</th>
|
<th>Arch</th>
|
||||||
<th>Size</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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{{range .}}
|
{{range .}}
|
||||||
|
@ -245,7 +246,7 @@ $(document).ready(function() {
|
||||||
<td>{{.PrettyOS}}</td>
|
<td>{{.PrettyOS}}</td>
|
||||||
<td>{{pretty .Arch}}</td>
|
<td>{{pretty .Arch}}</td>
|
||||||
<td>{{.PrettySize}}</td>
|
<td>{{.PrettySize}}</td>
|
||||||
<td><tt>{{.Checksum}}</tt></td>
|
<td><tt>{{.PrettyChecksum}}</tt></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -263,7 +264,7 @@ $(document).ready(function() {
|
||||||
<span class="filename">{{.Filename}}</span>
|
<span class="filename">{{.Filename}}</span>
|
||||||
{{if .Size}}<span class="size">({{.PrettySize}})</span>{{end}}
|
{{if .Size}}<span class="size">({{.PrettySize}})</span>{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="checksum">SHA1: {{.Checksum}}</div>
|
<div class="checksum">{{.ChecksumType}}: {{.PrettyChecksum}}</div>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
|
Loading…
Reference in New Issue