From: Simon Ruderich Date: Wed, 26 May 2021 07:20:04 +0000 (+0200) Subject: remote: use defer to replace multiple dh.Close() X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=46b4e35255664aac9123231fc02500baac3c1955;p=safcm%2Fsafcm.git remote: use defer to replace multiple dh.Close() --- diff --git a/remote/sync/files.go b/remote/sync/files.go index 112c923..e3fc3d9 100644 --- a/remote/sync/files.go +++ b/remote/sync/files.go @@ -285,9 +285,10 @@ reopen: if err != nil { return err } + defer dh.Close() + err = dh.Chmod(file.Mode) if err != nil { - dh.Close() return err } // Less restrictive access is not relevant here because there @@ -295,10 +296,8 @@ reopen: debugf("chowning %d/%d", file.Uid, file.Gid) err = dh.Chown(file.Uid, file.Gid) if err != nil { - dh.Close() return err } - dh.Close() return nil } // Directory: changed permission or user/group