refactor: ignore already closed error (#1285)

* refactor: ignore already closed error

This hides the `file already cloesd` error as it is
distracting in the output and does not provide any value.

* refactor: use go errors

Co-authored-by: Casey Lee <caseypl@amazon.com>
This commit is contained in:
Markus Wolf 2022-08-07 08:07:54 +02:00 committed by GitHub
parent 3387fd72ee
commit 92ddcdae09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"bufio"
"bytes"
"context"
"errors"
"fmt"
"io"
"io/ioutil"
@ -696,7 +697,7 @@ func (cr *containerReference) copyDir(dstPath string, srcPath string, useGitIgno
defer func(tarFile *os.File) {
name := tarFile.Name()
err := tarFile.Close()
if err != nil {
if !errors.Is(err, os.ErrClosed) {
logger.Error(err)
}
err = os.Remove(name)