filesync: avoid ignoring close error

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 6bd2d45527)
v0.7
Tonis Tiigi 2020-05-08 17:48:56 -07:00
parent 77048aa4cd
commit 881d18e48d
1 changed files with 7 additions and 2 deletions

View File

@ -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)
}