refactor: fix defer and handle error

This commit is contained in:
Roxie Gibson 2021-08-31 16:02:38 +01:00
parent 7dce352366
commit 3b93f893fd
Signed by untrusted user: roxxers
GPG Key ID: 5D0140EDEE123F4D
1 changed files with 4 additions and 3 deletions

View File

@ -111,14 +111,15 @@ var appCpCommand = &cli.Command{
}
} else {
content, _, err := cl.CopyFromContainer(ctx, container.ID, srcPath)
defer content.Close()
if err != nil {
logrus.Fatal(err)
}
fromTarOpts := &archive.TarOptions{NoOverwriteDirNonDir: true, Compression: archive.Gzip}
archive.Untar(content, dstPath, fromTarOpts)
defer content.Close()
if err := archive.Untar(content, dstPath, fromTarOpts); err != nil {
logrus.Fatal(err)
}
}
return nil
},
}