]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
remote: use defer to replace multiple dh.Close()
authorSimon Ruderich <simon@ruderich.org>
Wed, 26 May 2021 07:20:04 +0000 (09:20 +0200)
committerSimon Ruderich <simon@ruderich.org>
Wed, 26 May 2021 07:20:04 +0000 (09:20 +0200)
remote/sync/files.go

index 112c9237941a518559b2153dad1276be7a29351f..e3fc3d981a8c17c91f78a21bade00e3f5e607619 100644 (file)
@@ -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