Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
944b4bf4
Commit
944b4bf4
authored
Jun 22, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: delete file if checksum fails
parent
a5ac8066
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
builder/amazon/common/block_device_test.go
builder/amazon/common/block_device_test.go
+0
-2
common/download.go
common/download.go
+7
-2
No files found.
builder/amazon/common/block_device_test.go
View file @
944b4bf4
...
@@ -46,7 +46,6 @@ func TestBlockDevice(t *testing.T) {
...
@@ -46,7 +46,6 @@ func TestBlockDevice(t *testing.T) {
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
VirtualName
:
aws
.
String
(
""
),
VirtualName
:
aws
.
String
(
""
),
EBS
:
&
ec2
.
EBSBlockDevice
{
EBS
:
&
ec2
.
EBSBlockDevice
{
Encrypted
:
aws
.
Boolean
(
false
),
VolumeType
:
aws
.
String
(
""
),
VolumeType
:
aws
.
String
(
""
),
VolumeSize
:
aws
.
Long
(
8
),
VolumeSize
:
aws
.
Long
(
8
),
DeleteOnTermination
:
aws
.
Boolean
(
false
),
DeleteOnTermination
:
aws
.
Boolean
(
false
),
...
@@ -67,7 +66,6 @@ func TestBlockDevice(t *testing.T) {
...
@@ -67,7 +66,6 @@ func TestBlockDevice(t *testing.T) {
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
VirtualName
:
aws
.
String
(
"ephemeral0"
),
VirtualName
:
aws
.
String
(
"ephemeral0"
),
EBS
:
&
ec2
.
EBSBlockDevice
{
EBS
:
&
ec2
.
EBSBlockDevice
{
Encrypted
:
aws
.
Boolean
(
false
),
VolumeType
:
aws
.
String
(
"io1"
),
VolumeType
:
aws
.
String
(
"io1"
),
VolumeSize
:
aws
.
Long
(
8
),
VolumeSize
:
aws
.
Long
(
8
),
DeleteOnTermination
:
aws
.
Boolean
(
true
),
DeleteOnTermination
:
aws
.
Boolean
(
true
),
...
...
common/download.go
View file @
944b4bf4
...
@@ -136,10 +136,10 @@ func (d *DownloadClient) Get() (string, error) {
...
@@ -136,10 +136,10 @@ func (d *DownloadClient) Get() (string, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
defer
f
.
Close
()
log
.
Printf
(
"Downloading: %s"
,
url
.
String
())
log
.
Printf
(
"Downloading: %s"
,
url
.
String
())
err
=
d
.
downloader
.
Download
(
f
,
url
)
err
=
d
.
downloader
.
Download
(
f
,
url
)
f
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -149,7 +149,12 @@ func (d *DownloadClient) Get() (string, error) {
...
@@ -149,7 +149,12 @@ func (d *DownloadClient) Get() (string, error) {
var
verify
bool
var
verify
bool
verify
,
err
=
d
.
VerifyChecksum
(
finalPath
)
verify
,
err
=
d
.
VerifyChecksum
(
finalPath
)
if
err
==
nil
&&
!
verify
{
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
))
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment