[lxc-devel] [lxd/master] shared/util: Add DownloadFileMd5

monstermunchkin on Github lxc-bot at linuxcontainers.org
Wed Dec 19 13:35:11 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 482 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181219/3a1b61a6/attachment.bin>
-------------- next part --------------
From b66336172bf8fce16e16e7c48424a18dc635a55b Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 19 Dec 2018 14:30:02 +0100
Subject: [PATCH] shared/util: Add DownloadFileMd5

This function is needed by distrobuilder for Sabayon Linux, since the
distro only provides MD5 checksums for their images.

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 shared/util.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/shared/util.go b/shared/util.go
index e24c066a02..1e253521f8 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -3,6 +3,7 @@ package shared
 import (
 	"bufio"
 	"bytes"
+	"crypto/md5"
 	"crypto/rand"
 	"crypto/sha256"
 	"crypto/sha512"
@@ -1010,6 +1011,10 @@ func EscapePathFstab(path string) string {
 	return r.Replace(path)
 }
 
+func DownloadFileMd5(httpClient *http.Client, useragent string, progress func(progress ioprogress.ProgressData), canceler *cancel.Canceler, filename string, url string, hash string, target io.WriteSeeker) (int64, error) {
+	return downloadFileSha(httpClient, useragent, progress, canceler, filename, url, hash, md5.New(), target)
+}
+
 func DownloadFileSha256(httpClient *http.Client, useragent string, progress func(progress ioprogress.ProgressData), canceler *cancel.Canceler, filename string, url string, hash string, target io.WriteSeeker) (int64, error) {
 	return downloadFileSha(httpClient, useragent, progress, canceler, filename, url, hash, sha256.New(), target)
 }


More information about the lxc-devel mailing list