diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-08-04 15:41:24 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-08-09 10:59:36 +0300 |
commit | 631638faef0292271e674cefeb87cf3af60f4281 (patch) | |
tree | 2c11a235f1526d4222c63211f95194073948609c /internal/tempdir | |
parent | 5954eb119126a97c80a0d6e69114b8e1bc349b7e (diff) |
lint: Handle error returned by os.RemoveAll
The change removes os.RemoveAll from lint rules exclusion
and fixes all the places where it causes the issue.
If removal ends up with an error we try to log it if the
logger is accessible. Otherwise the error is just omitted.
We don't return it back to the caller because we don't want
functional changes here.
Diffstat (limited to 'internal/tempdir')
-rw-r--r-- | internal/tempdir/tempdir.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/tempdir/tempdir.go b/internal/tempdir/tempdir.go index 7fde16344..d0fd90e3c 100644 --- a/internal/tempdir/tempdir.go +++ b/internal/tempdir/tempdir.go @@ -8,6 +8,7 @@ import ( "path/filepath" "time" + "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" ) @@ -96,7 +97,9 @@ func newDirectory(ctx context.Context, storageName string, prefix string, loc st func (d Dir) cleanupOnDone(ctx context.Context) { <-ctx.Done() - os.RemoveAll(d.Path()) + if err := os.RemoveAll(d.Path()); err != nil { + ctxlogrus.Extract(ctx).WithError(err).Errorf("failed to cleanup temp dir %q", d.path) + } close(d.doneCh) } |