mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 04:45:15 +00:00
archiver: improve error message for irregular files
Since Go 1.21, most reparse points are considered as irregular files. Depending on the underlying driver these can exhibit nearly arbitrary behavior. When encountering such a file, restic returned an indecipherable error message: `error: invalid node type ""`. Add the filepath to the error message and state that the file type is not supported.
This commit is contained in:
parent
c95de54726
commit
e886c3f6b2
@ -2,6 +2,7 @@ package archiver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
@ -183,7 +184,10 @@ func (arch *Archiver) nodeFromFileInfo(snPath, filename string, fi os.FileInfo)
|
||||
}
|
||||
// overwrite name to match that within the snapshot
|
||||
node.Name = path.Base(snPath)
|
||||
return node, errors.WithStack(err)
|
||||
if err != nil {
|
||||
return node, fmt.Errorf("nodeFromFileInfo %v: %w", filename, err)
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// loadSubtree tries to load the subtree referenced by node. In case of an error, nil is returned.
|
||||
|
@ -124,6 +124,8 @@ func nodeTypeFromFileInfo(fi os.FileInfo) string {
|
||||
return "fifo"
|
||||
case os.ModeSocket:
|
||||
return "socket"
|
||||
case os.ModeIrregular:
|
||||
return "irregular"
|
||||
}
|
||||
|
||||
return ""
|
||||
@ -622,7 +624,7 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error {
|
||||
case "fifo":
|
||||
case "socket":
|
||||
default:
|
||||
return errors.Errorf("invalid node type %q", node.Type)
|
||||
return errors.Errorf("unsupported file type %q", node.Type)
|
||||
}
|
||||
|
||||
return node.fillExtendedAttributes(path)
|
||||
|
Loading…
Reference in New Issue
Block a user