Select specific Node fields for listing

This commit is contained in:
Matthew Holt 2018-08-19 09:03:47 -06:00
parent 04c67d700d
commit 22475729ce
2 changed files with 24 additions and 4 deletions

View File

@ -3,7 +3,9 @@ package main
import (
"context"
"encoding/json"
"os"
"strings"
"time"
"github.com/spf13/cobra"
@ -68,7 +70,16 @@ type lsSnapshot struct {
}
type lsNode struct {
*restic.Node
Name string `json:"name"`
Type string `json:"type"`
Path string `json:"path"`
UID uint32 `json:"uid"`
GID uint32 `json:"gid"`
Size uint64 `json:"size,omitempty"`
Mode os.FileMode `json:"mode,omitempty"`
ModTime time.Time `json:"mtime,omitempty"`
AccessTime time.Time `json:"atime,omitempty"`
ChangeTime time.Time `json:"ctime,omitempty"`
StructType string `json:"struct_type"` // "node"
}
@ -153,7 +164,16 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
printNode = func(path string, node *restic.Node) {
enc.Encode(lsNode{
Node: node,
Name: node.Name,
Type: node.Type,
Path: path,
UID: node.UID,
GID: node.GID,
Size: node.Size,
Mode: node.Mode,
ModTime: node.ModTime,
AccessTime: node.AccessTime,
ChangeTime: node.ChangeTime,
StructType: "node",
})
}

View File

@ -50,7 +50,7 @@ type Node struct {
Error string `json:"error,omitempty"`
Path string `json:"path"`
Path string `json:"-"`
}
// Nodes is a slice of nodes that can be sorted.