From 19653f9e06ffeede08ffd9387b39c19eabcc9ef8 Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:36:48 +0200 Subject: [PATCH] fs: Simplify NodeCreateAt --- internal/fs/node.go | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/internal/fs/node.go b/internal/fs/node.go index 280e290c2..a5ca1654a 100644 --- a/internal/fs/node.go +++ b/internal/fs/node.go @@ -163,41 +163,29 @@ func lookupGroup(gid uint32) string { } // NodeCreateAt creates the node at the given path but does NOT restore node meta data. -func NodeCreateAt(node *restic.Node, path string) error { +func NodeCreateAt(node *restic.Node, path string) (err error) { debug.Log("create node %v at %v", node.Name, path) switch node.Type { case restic.NodeTypeDir: - if err := nodeCreateDirAt(node, path); err != nil { - return err - } + err = nodeCreateDirAt(node, path) case restic.NodeTypeFile: - if err := nodeCreateFileAt(path); err != nil { - return err - } + err = nodeCreateFileAt(path) case restic.NodeTypeSymlink: - if err := nodeCreateSymlinkAt(node, path); err != nil { - return err - } + err = nodeCreateSymlinkAt(node, path) case restic.NodeTypeDev: - if err := nodeCreateDevAt(node, path); err != nil { - return err - } + err = nodeCreateDevAt(node, path) case restic.NodeTypeCharDev: - if err := nodeCreateCharDevAt(node, path); err != nil { - return err - } + err = nodeCreateCharDevAt(node, path) case restic.NodeTypeFifo: - if err := nodeCreateFifoAt(path); err != nil { - return err - } + err = nodeCreateFifoAt(path) case restic.NodeTypeSocket: - return nil + err = nil default: - return errors.Errorf("filetype %q not implemented", node.Type) + err = errors.Errorf("filetype %q not implemented", node.Type) } - return nil + return err } func nodeCreateDirAt(node *restic.Node, path string) error {