find: Use OS independent slash-based format
This commit is contained in:
parent
42ebb0a0a6
commit
e2d347a698
2 changed files with 7 additions and 7 deletions
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"path/filepath"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ func (s *statefulOutput) PrintJSON(prefix string, node *restic.Node) {
|
||||||
Content byte `json:"content,omitempty"`
|
Content byte `json:"content,omitempty"`
|
||||||
Subtree byte `json:"subtree,omitempty"`
|
Subtree byte `json:"subtree,omitempty"`
|
||||||
}{
|
}{
|
||||||
Path: filepath.Join(prefix, node.Name),
|
Path: path.Join(prefix, node.Name),
|
||||||
Permissions: node.Mode.String(),
|
Permissions: node.Mode.String(),
|
||||||
findNode: (*findNode)(node),
|
findNode: (*findNode)(node),
|
||||||
})
|
})
|
||||||
|
@ -202,7 +202,7 @@ func (f *Finder) findInTree(ctx context.Context, treeID restic.ID, prefix string
|
||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
m, err := filepath.Match(f.pat.pattern, name)
|
m, err := path.Match(f.pat.pattern, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ func (f *Finder) findInTree(ctx context.Context, treeID restic.ID, prefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Type == "dir" {
|
if node.Type == "dir" {
|
||||||
if err := f.findInTree(ctx, *node.Subtree, filepath.Join(prefix, node.Name)); err != nil {
|
if err := f.findInTree(ctx, *node.Subtree, path.Join(prefix, node.Name)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error
|
||||||
debug.Log("searching in snapshot %s\n for entries within [%s %s]", sn.ID(), f.pat.oldest, f.pat.newest)
|
debug.Log("searching in snapshot %s\n for entries within [%s %s]", sn.ID(), f.pat.oldest, f.pat.newest)
|
||||||
|
|
||||||
f.out.newsn = sn
|
f.out.newsn = sn
|
||||||
return f.findInTree(ctx, *sn.Tree, string(filepath.Separator))
|
return f.findInTree(ctx, *sn.Tree, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func runFind(opts FindOptions, gopts GlobalOptions, args []string) error {
|
func runFind(opts FindOptions, gopts GlobalOptions, args []string) error {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
|
@ -64,7 +64,7 @@ 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
|
nodepath := path.Join(prefix, n.Name)
|
||||||
if !long {
|
if !long {
|
||||||
return nodepath
|
return nodepath
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue