From a069467e72d791796e2ea2ed665fa2f523132e06 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 30 Mar 2018 22:35:18 +0200 Subject: [PATCH] ls: Improve output --- cmd/restic/cmd_ls.go | 5 +++-- cmd/restic/format.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go index 4a046b7ef..d4a768d70 100644 --- a/cmd/restic/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -56,7 +56,8 @@ func printTree(ctx context.Context, repo *repository.Repository, id *restic.ID, Printf("%s\n", formatNode(prefix, entry, lsOptions.ListLong)) if entry.Type == "dir" && entry.Subtree != nil { - if err = printTree(ctx, repo, entry.Subtree, filepath.Join(prefix, entry.Name)); err != nil { + entryPath := prefix + string(filepath.Separator) + entry.Name + if err = printTree(ctx, repo, entry.Subtree, entryPath); err != nil { return err } } @@ -84,7 +85,7 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error { for sn := range FindFilteredSnapshots(ctx, repo, opts.Host, opts.Tags, opts.Paths, args) { Verbosef("snapshot %s of %v at %s):\n", sn.ID().Str(), sn.Paths, sn.Time) - if err = printTree(gopts.ctx, repo, sn.Tree, string(filepath.Separator)); err != nil { + if err = printTree(gopts.ctx, repo, sn.Tree, ""); err != nil { return err } } diff --git a/cmd/restic/format.go b/cmd/restic/format.go index 9f66d1c1d..1f8ab366e 100644 --- a/cmd/restic/format.go +++ b/cmd/restic/format.go @@ -64,8 +64,9 @@ func formatDuration(d time.Duration) string { } func formatNode(prefix string, n *restic.Node, long bool) string { + nodepath := prefix + string(filepath.Separator) + n.Name if !long { - return filepath.Join(prefix, n.Name) + return nodepath } var mode os.FileMode @@ -91,6 +92,6 @@ func formatNode(prefix string, n *restic.Node, long bool) string { return fmt.Sprintf("%s %5d %5d %6d %s %s%s", mode|n.Mode, n.UID, n.GID, n.Size, - n.ModTime.Format(TimeFormat), filepath.Join(prefix, n.Name), + n.ModTime.Format(TimeFormat), nodepath, target) }