close the temp file after cleaning

This commit is contained in:
Rick Olson 2014-08-07 15:32:45 -06:00
parent 212f3a2d6d
commit a3795ffb51
2 changed files with 7 additions and 2 deletions

@ -44,9 +44,10 @@ func cleanCommand(cmd *cobra.Command, args []string) {
file.Close()
}
defer cleaned.Close()
cleaned.Close()
defer cleaned.Teardown()
if err != nil {
Panic(err, "Error cleaning asset")
Panic(err, "Error cleaning asset.")
}
tmpfile := cleaned.File.Name()

@ -34,5 +34,9 @@ func Clean(reader io.Reader, size int64, cb gitmedia.CopyCallback) (*cleanedAsse
}
func (a *cleanedAsset) Close() error {
return a.File.Close()
}
func (a *cleanedAsset) Teardown() error {
return os.Remove(a.File.Name())
}