mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-22 16:01:43 -04:00
common: delete file if checksum fails
This commit is contained in:
@@ -46,7 +46,6 @@ func TestBlockDevice(t *testing.T) {
|
||||
DeviceName: aws.String("/dev/sdb"),
|
||||
VirtualName: aws.String(""),
|
||||
EBS: &ec2.EBSBlockDevice{
|
||||
Encrypted: aws.Boolean(false),
|
||||
VolumeType: aws.String(""),
|
||||
VolumeSize: aws.Long(8),
|
||||
DeleteOnTermination: aws.Boolean(false),
|
||||
@@ -67,7 +66,6 @@ func TestBlockDevice(t *testing.T) {
|
||||
DeviceName: aws.String("/dev/sdb"),
|
||||
VirtualName: aws.String("ephemeral0"),
|
||||
EBS: &ec2.EBSBlockDevice{
|
||||
Encrypted: aws.Boolean(false),
|
||||
VolumeType: aws.String("io1"),
|
||||
VolumeSize: aws.Long(8),
|
||||
DeleteOnTermination: aws.Boolean(true),
|
||||
|
||||
+7
-2
@@ -136,10 +136,10 @@ func (d *DownloadClient) Get() (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
log.Printf("Downloading: %s", url.String())
|
||||
err = d.downloader.Download(f, url)
|
||||
f.Close()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -149,7 +149,12 @@ func (d *DownloadClient) Get() (string, error) {
|
||||
var verify bool
|
||||
verify, err = d.VerifyChecksum(finalPath)
|
||||
if err == nil && !verify {
|
||||
err = fmt.Errorf("checksums didn't match expected: %s", hex.EncodeToString(d.config.Checksum))
|
||||
// Delete the file
|
||||
os.Remove(finalPath)
|
||||
|
||||
err = fmt.Errorf(
|
||||
"checksums didn't match expected: %s",
|
||||
hex.EncodeToString(d.config.Checksum))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user