From 3b93f893fdd5ba90e35ba842ee0bb9db3af629bf Mon Sep 17 00:00:00 2001 From: Roxie Gibson Date: Tue, 31 Aug 2021 16:02:38 +0100 Subject: [PATCH] refactor: fix defer and handle error --- cli/app/cp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/app/cp.go b/cli/app/cp.go index a4476abc..63087d49 100644 --- a/cli/app/cp.go +++ b/cli/app/cp.go @@ -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 }, }