mirror of
https://github.com/restic/restic.git
synced 2025-08-26 09:28:01 +00:00
add proper constants for node type
This commit is contained in:
@@ -65,7 +65,7 @@ func NewSnapshotSizeRewriter(rewriteNode NodeRewriteFunc) (*TreeRewriter, QueryR
|
||||
t := NewTreeRewriter(RewriteOpts{
|
||||
RewriteNode: func(node *restic.Node, path string) *restic.Node {
|
||||
node = rewriteNode(node, path)
|
||||
if node != nil && node.Type == "file" {
|
||||
if node != nil && node.Type == restic.NodeTypeFile {
|
||||
count++
|
||||
size += node.Size
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func (t *TreeRewriter) RewriteTree(ctx context.Context, repo BlobLoadSaver, node
|
||||
continue
|
||||
}
|
||||
|
||||
if node.Type != "dir" {
|
||||
if node.Type != restic.NodeTypeDir {
|
||||
err = tb.AddNode(node)
|
||||
if err != nil {
|
||||
return restic.ID{}, err
|
||||
|
@@ -110,7 +110,7 @@ func checkIncreaseNodeSize(increase uint64) checkRewriteFunc {
|
||||
return func(t testing.TB) (rewriter *TreeRewriter, final func(testing.TB)) {
|
||||
rewriter = NewTreeRewriter(RewriteOpts{
|
||||
RewriteNode: func(node *restic.Node, path string) *restic.Node {
|
||||
if node.Type == "file" {
|
||||
if node.Type == restic.NodeTypeFile {
|
||||
node.Size += increase
|
||||
}
|
||||
return node
|
||||
@@ -329,7 +329,7 @@ func TestSnapshotSizeQuery(t *testing.T) {
|
||||
if path == "/bar" {
|
||||
return nil
|
||||
}
|
||||
if node.Type == "file" {
|
||||
if node.Type == restic.NodeTypeFile {
|
||||
node.Size += 21
|
||||
}
|
||||
return node
|
||||
|
@@ -63,11 +63,11 @@ func walk(ctx context.Context, repo restic.BlobLoader, prefix string, parentTree
|
||||
|
||||
p := path.Join(prefix, node.Name)
|
||||
|
||||
if node.Type == "" {
|
||||
if node.Type == restic.NodeTypeInvalid {
|
||||
return errors.Errorf("node type is empty for node %q", node.Name)
|
||||
}
|
||||
|
||||
if node.Type != "dir" {
|
||||
if node.Type != restic.NodeTypeDir {
|
||||
err := visitor.ProcessNode(parentTreeID, p, node, nil)
|
||||
if err != nil {
|
||||
if err == ErrSkipNode {
|
||||
|
@@ -38,7 +38,7 @@ func buildTreeMap(tree TestTree, m TreeMap) restic.ID {
|
||||
case TestFile:
|
||||
err := tb.AddNode(&restic.Node{
|
||||
Name: name,
|
||||
Type: "file",
|
||||
Type: restic.NodeTypeFile,
|
||||
Size: elem.Size,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -49,7 +49,7 @@ func buildTreeMap(tree TestTree, m TreeMap) restic.ID {
|
||||
err := tb.AddNode(&restic.Node{
|
||||
Name: name,
|
||||
Subtree: &id,
|
||||
Type: "dir",
|
||||
Type: restic.NodeTypeDir,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Reference in New Issue
Block a user