From a016f8205168a489dcc214458d256e119751e513 Mon Sep 17 00:00:00 2001 From: Matthieu Rakotojaona Date: Sun, 19 Jul 2015 14:08:34 +0200 Subject: [PATCH] Fix coding style --- cmd/restic/cmd_mount.go | 27 ++++++++++++--------------- cmd/restic/integration_fuse_test.go | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/cmd/restic/cmd_mount.go b/cmd/restic/cmd_mount.go index d26634ad4..442637180 100644 --- a/cmd/restic/cmd_mount.go +++ b/cmd/restic/cmd_mount.go @@ -59,13 +59,11 @@ func (cmd CmdMount) Execute(args []string) error { } mountpoint := args[0] - if _, err := os.Stat(mountpoint); err != nil { - if os.IsNotExist(err) { - cmd.global.Verbosef("Mountpoint %s doesn't exist, creating it\n", mountpoint) - err = os.Mkdir(mountpoint, os.ModeDir|0700) - if err != nil { - return err - } + if _, err := os.Stat(mountpoint); os.IsNotExist(err) { + cmd.global.Verbosef("Mountpoint %s doesn't exist, creating it\n", mountpoint) + err = os.Mkdir(mountpoint, os.ModeDir|0700) + if err != nil { + return err } } c, err := fuse.Mount( @@ -83,8 +81,8 @@ func (cmd CmdMount) Execute(args []string) error { knownSnapshots: make(map[string]snapshotWithId), }) - cmd.global.Printf("Now serving %s under %s\n", repo.Backend().Location(), mountpoint) - cmd.global.Printf("Don't forget to umount after quitting !\n") + cmd.global.Printf("Now serving %s at %s\n", repo.Backend().Location(), mountpoint) + cmd.global.Printf("Don't forget to umount after quitting!\n") cmd.ready <- struct{}{} @@ -116,9 +114,9 @@ type snapshots struct { knownSnapshots map[string]snapshotWithId } -func (sn *snapshots) Attr(ctx context.Context, a *fuse.Attr) error { - a.Inode = 0 - a.Mode = os.ModeDir | 0555 +func (sn *snapshots) Attr(ctx context.Context, attr *fuse.Attr) error { + attr.Inode = 0 + attr.Mode = os.ModeDir | 0555 return nil } @@ -247,7 +245,6 @@ func (d *dir) Lookup(ctx context.Context, name string) (fs.Node, error) { } } - return nil, fuse.ENOENT } // Statically ensure that *file implements the given interface @@ -265,8 +262,8 @@ type file struct { func makeFile(repo *repository.Repository, node *restic.Node) (*file, error) { sizes := make([]uint32, len(node.Content)) - for i, bid := range node.Content { - _, _, _, length, err := repo.Index().Lookup(bid) + for i, blobId := range node.Content { + _, _, _, length, err := repo.Index().Lookup(blobId) if err != nil { return nil, err } diff --git a/cmd/restic/integration_fuse_test.go b/cmd/restic/integration_fuse_test.go index f12b714e7..0754c0e72 100644 --- a/cmd/restic/integration_fuse_test.go +++ b/cmd/restic/integration_fuse_test.go @@ -34,7 +34,7 @@ func TestMount(t *testing.T) { OK(t, err) Assert(t, namesInSnapshots[i] == snapshot.Time.Format(time.RFC3339), - "Invalid snapshot folder name: expected %s, got %s", snapshot.Time.Format(time.RFC3339), namesInSnapshots[i]) + "Invalid snapshot directory name: expected %s, got %s", snapshot.Time.Format(time.RFC3339), namesInSnapshots[i]) } OK(t, stSnapshots.Close()) }