mirror of
https://github.com/octoleo/restic.git
synced 2024-11-21 20:35:12 +00:00
fix linter warning
This commit is contained in:
parent
4bae54d040
commit
a2f2f8fb4c
@ -148,8 +148,8 @@ func lsNodeJSON(enc *json.Encoder, path string, node *restic.Node) error {
|
|||||||
return enc.Encode(n)
|
return enc.Encode(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *jsonLsPrinter) LeaveDir(path string) {}
|
func (p *jsonLsPrinter) LeaveDir(_ string) {}
|
||||||
func (p *jsonLsPrinter) Close() {}
|
func (p *jsonLsPrinter) Close() {}
|
||||||
|
|
||||||
type ncduLsPrinter struct {
|
type ncduLsPrinter struct {
|
||||||
out io.Writer
|
out io.Writer
|
||||||
@ -171,7 +171,7 @@ func (p *ncduLsPrinter) Snapshot(sn *restic.Snapshot) {
|
|||||||
fmt.Fprintf(p.out, "[%d, %d, %s", NcduMajorVer, NcduMinorVer, string(snapshotBytes))
|
fmt.Fprintf(p.out, "[%d, %d, %s", NcduMajorVer, NcduMinorVer, string(snapshotBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
func lsNcduNode(path string, node *restic.Node) ([]byte, error) {
|
func lsNcduNode(_ string, node *restic.Node) ([]byte, error) {
|
||||||
type NcduNode struct {
|
type NcduNode struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Asize uint64 `json:"asize"`
|
Asize uint64 `json:"asize"`
|
||||||
@ -180,8 +180,8 @@ func lsNcduNode(path string, node *restic.Node) ([]byte, error) {
|
|||||||
Ino uint64 `json:"ino"`
|
Ino uint64 `json:"ino"`
|
||||||
NLink uint64 `json:"nlink"`
|
NLink uint64 `json:"nlink"`
|
||||||
NotReg bool `json:"notreg"`
|
NotReg bool `json:"notreg"`
|
||||||
Uid uint32 `json:"uid"`
|
UID uint32 `json:"uid"`
|
||||||
Gid uint32 `json:"gid"`
|
GID uint32 `json:"gid"`
|
||||||
Mode uint16 `json:"mode"`
|
Mode uint16 `json:"mode"`
|
||||||
Mtime int64 `json:"mtime"`
|
Mtime int64 `json:"mtime"`
|
||||||
}
|
}
|
||||||
@ -194,8 +194,8 @@ func lsNcduNode(path string, node *restic.Node) ([]byte, error) {
|
|||||||
Ino: node.Inode,
|
Ino: node.Inode,
|
||||||
NLink: node.Links,
|
NLink: node.Links,
|
||||||
NotReg: node.Type != "dir" && node.Type != "file",
|
NotReg: node.Type != "dir" && node.Type != "file",
|
||||||
Uid: node.UID,
|
UID: node.UID,
|
||||||
Gid: node.GID,
|
GID: node.GID,
|
||||||
Mode: uint16(node.Mode & os.ModePerm),
|
Mode: uint16(node.Mode & os.ModePerm),
|
||||||
Mtime: node.ModTime.Unix(),
|
Mtime: node.ModTime.Unix(),
|
||||||
}
|
}
|
||||||
@ -214,20 +214,20 @@ func lsNcduNode(path string, node *restic.Node) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ncduLsPrinter) Node(path string, node *restic.Node) {
|
func (p *ncduLsPrinter) Node(path string, node *restic.Node) {
|
||||||
outJson, err := lsNcduNode(path, node)
|
out, err := lsNcduNode(path, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Warnf("JSON encode failed: %v\n", err)
|
Warnf("JSON encode failed: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Type == "dir" {
|
if node.Type == "dir" {
|
||||||
fmt.Fprintf(p.out, ",\n%s[\n%s%s", strings.Repeat(" ", p.depth), strings.Repeat(" ", p.depth+1), string(outJson))
|
fmt.Fprintf(p.out, ",\n%s[\n%s%s", strings.Repeat(" ", p.depth), strings.Repeat(" ", p.depth+1), string(out))
|
||||||
p.depth++
|
p.depth++
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(p.out, ",\n%s%s", strings.Repeat(" ", p.depth), string(outJson))
|
fmt.Fprintf(p.out, ",\n%s%s", strings.Repeat(" ", p.depth), string(out))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ncduLsPrinter) LeaveDir(path string) {
|
func (p *ncduLsPrinter) LeaveDir(_ string) {
|
||||||
p.depth--
|
p.depth--
|
||||||
fmt.Fprintf(p.out, "\n%s]", strings.Repeat(" ", p.depth))
|
fmt.Fprintf(p.out, "\n%s]", strings.Repeat(" ", p.depth))
|
||||||
}
|
}
|
||||||
@ -249,8 +249,8 @@ func (p *textLsPrinter) Node(path string, node *restic.Node) {
|
|||||||
Printf("%s\n", formatNode(path, node, p.ListLong, p.HumanReadable))
|
Printf("%s\n", formatNode(path, node, p.ListLong, p.HumanReadable))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *textLsPrinter) LeaveDir(path string) {}
|
func (p *textLsPrinter) LeaveDir(_ string) {}
|
||||||
func (p *textLsPrinter) Close() {}
|
func (p *textLsPrinter) Close() {}
|
||||||
|
|
||||||
func runLs(ctx context.Context, opts LsOptions, gopts GlobalOptions, args []string) error {
|
func runLs(ctx context.Context, opts LsOptions, gopts GlobalOptions, args []string) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
|
@ -24,7 +24,7 @@ func testRunLs(t testing.TB, gopts GlobalOptions, snapshotID string) []string {
|
|||||||
return strings.Split(string(out), "\n")
|
return strings.Split(string(out), "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertIsValidJson(t *testing.T, data []byte) {
|
func assertIsValidJSON(t *testing.T, data []byte) {
|
||||||
// Sanity check: output must be valid JSON.
|
// Sanity check: output must be valid JSON.
|
||||||
var v interface{}
|
var v interface{}
|
||||||
err := json.Unmarshal(data, &v)
|
err := json.Unmarshal(data, &v)
|
||||||
@ -40,8 +40,8 @@ func TestRunLsNcdu(t *testing.T) {
|
|||||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
||||||
|
|
||||||
ncdu := testRunLsWithOpts(t, env.gopts, LsOptions{Ncdu: true}, []string{"latest"})
|
ncdu := testRunLsWithOpts(t, env.gopts, LsOptions{Ncdu: true}, []string{"latest"})
|
||||||
assertIsValidJson(t, ncdu)
|
assertIsValidJSON(t, ncdu)
|
||||||
|
|
||||||
ncdu = testRunLsWithOpts(t, env.gopts, LsOptions{Ncdu: true}, []string{"latest", "/testdata"})
|
ncdu = testRunLsWithOpts(t, env.gopts, LsOptions{Ncdu: true}, []string{"latest", "/testdata"})
|
||||||
assertIsValidJson(t, ncdu)
|
assertIsValidJSON(t, ncdu)
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ type lsTestNode struct {
|
|||||||
restic.Node
|
restic.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
var lsTestNodes []lsTestNode = []lsTestNode{
|
var lsTestNodes = []lsTestNode{
|
||||||
// Mode is omitted when zero.
|
// Mode is omitted when zero.
|
||||||
// Permissions, by convention is "-" per mode bit
|
// Permissions, by convention is "-" per mode bit
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user