From 6bd2d45527fcb830578da910f8efb0be7d919293 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 8 May 2020 17:48:56 -0700 Subject: [PATCH] filesync: avoid ignoring close error Signed-off-by: Tonis Tiigi --- session/filesync/filesync.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/session/filesync/filesync.go b/session/filesync/filesync.go index a45abe02..51dd3c53 100644 --- a/session/filesync/filesync.go +++ b/session/filesync/filesync.go @@ -255,7 +255,7 @@ func (sp *fsSyncTarget) Register(server *grpc.Server) { RegisterFileSendServer(server, sp) } -func (sp *fsSyncTarget) DiffCopy(stream FileSend_DiffCopyServer) error { +func (sp *fsSyncTarget) DiffCopy(stream FileSend_DiffCopyServer) (err error) { if sp.outdir != "" { return syncTargetDiffCopy(stream, sp.outdir) } @@ -277,7 +277,12 @@ func (sp *fsSyncTarget) DiffCopy(stream FileSend_DiffCopyServer) error { if wc == nil { return status.Errorf(codes.AlreadyExists, "target already exists") } - defer wc.Close() + defer func() { + err1 := wc.Close() + if err != nil { + err = err1 + } + }() return writeTargetFile(stream, wc) }