Had io.Copy args swapped; also use os.Create instead of os.OpenFile for MAGIC

This commit is contained in:
Chris Bednarski 2015-06-15 18:56:09 -07:00
parent 9c5845e3c7
commit 29f02d243f
1 changed files with 3 additions and 2 deletions

View File

@ -57,14 +57,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
return nil, err
}
target, err := os.OpenFile(b.config.Target, os.O_WRONLY, 0600)
// Create will truncate an existing file
target, err := os.Create(b.config.Target)
defer target.Close()
if err != nil {
return nil, err
}
ui.Say(fmt.Sprintf("Copying %s to %s", source.Name(), target.Name()))
bytes, err := io.Copy(source, target)
bytes, err := io.Copy(target, source)
if err != nil {
return nil, err
}