mirror of
https://github.com/gohugoio/hugo.git
synced 2025-06-29 12:19:51 +00:00
parent
43f9df0194
commit
822dc627a1
20 changed files with 633 additions and 74 deletions
|
@ -394,11 +394,10 @@ func MD5FromFileFast(r io.ReadSeeker) (string, error) {
|
|||
return hex.EncodeToString(h.Sum(nil)), nil
|
||||
}
|
||||
|
||||
// MD5FromFile creates a MD5 hash from the given file.
|
||||
// It will not close the file.
|
||||
func MD5FromFile(f afero.File) (string, error) {
|
||||
// MD5FromReader creates a MD5 hash from the given reader.
|
||||
func MD5FromReader(r io.Reader) (string, error) {
|
||||
h := md5.New()
|
||||
if _, err := io.Copy(h, f); err != nil {
|
||||
if _, err := io.Copy(h, r); err != nil {
|
||||
return "", nil
|
||||
}
|
||||
return hex.EncodeToString(h.Sum(nil)), nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue