backup download: remove file if there's an error

Signed-off-by: Andy Goldstein <andy.goldstein@gmail.com>
This commit is contained in:
Andy Goldstein
2017-10-26 11:09:35 -04:00
parent a3302d3d85
commit 8a53cef7e6
+4 -1
View File
@@ -107,7 +107,10 @@ func (o *DownloadOptions) Run(c *cobra.Command, f client.Factory) error {
defer backupDest.Close()
err = downloadrequest.Stream(arkClient.ArkV1(), o.Name, v1.DownloadTargetKindBackupContents, backupDest, o.Timeout)
cmd.CheckError(err)
if err != nil {
os.Remove(o.Output)
cmd.CheckError(err)
}
fmt.Printf("Backup %s has been successfully downloaded to %s\n", o.Name, backupDest.Name())
return nil