forked from TrueCloudLab/restic
Select specific Node fields for listing
This commit is contained in:
parent
04c67d700d
commit
22475729ce
2 changed files with 24 additions and 4 deletions
|
@ -3,7 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
@ -68,8 +70,17 @@ type lsSnapshot struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type lsNode struct {
|
type lsNode struct {
|
||||||
*restic.Node
|
Name string `json:"name"`
|
||||||
StructType string `json:"struct_type"` // "node"
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
|
func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
|
||||||
|
@ -153,7 +164,16 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
|
||||||
|
|
||||||
printNode = func(path string, node *restic.Node) {
|
printNode = func(path string, node *restic.Node) {
|
||||||
enc.Encode(lsNode{
|
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",
|
StructType: "node",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ type Node struct {
|
||||||
|
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
|
|
||||||
Path string `json:"path"`
|
Path string `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nodes is a slice of nodes that can be sorted.
|
// Nodes is a slice of nodes that can be sorted.
|
||||||
|
|
Loading…
Add table
Reference in a new issue