mirror of
https://github.com/restic/restic.git
synced 2025-12-10 22:31:47 +00:00
ls: Improve output
This commit is contained in:
@@ -56,7 +56,8 @@ func printTree(ctx context.Context, repo *repository.Repository, id *restic.ID,
|
|||||||
Printf("%s\n", formatNode(prefix, entry, lsOptions.ListLong))
|
Printf("%s\n", formatNode(prefix, entry, lsOptions.ListLong))
|
||||||
|
|
||||||
if entry.Type == "dir" && entry.Subtree != nil {
|
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
|
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) {
|
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)
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,9 @@ func formatDuration(d time.Duration) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func formatNode(prefix string, n *restic.Node, long bool) string {
|
func formatNode(prefix string, n *restic.Node, long bool) string {
|
||||||
|
nodepath := prefix + string(filepath.Separator) + n.Name
|
||||||
if !long {
|
if !long {
|
||||||
return filepath.Join(prefix, n.Name)
|
return nodepath
|
||||||
}
|
}
|
||||||
|
|
||||||
var mode os.FileMode
|
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",
|
return fmt.Sprintf("%s %5d %5d %6d %s %s%s",
|
||||||
mode|n.Mode, n.UID, n.GID, n.Size,
|
mode|n.Mode, n.UID, n.GID, n.Size,
|
||||||
n.ModTime.Format(TimeFormat), filepath.Join(prefix, n.Name),
|
n.ModTime.Format(TimeFormat), nodepath,
|
||||||
target)
|
target)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user