mirror of
https://github.com/restic/restic.git
synced 2026-10-06 02:40:31 +00:00
add proper constants for node type
This commit is contained in:
+2
-17
@@ -67,7 +67,7 @@ func sendNodes(ctx context.Context, repo restic.BlobLoader, root *restic.Node, c
|
||||
}
|
||||
|
||||
// If this is no directory we are finished
|
||||
if !IsDir(root) {
|
||||
if root.Type != restic.NodeTypeDir {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func sendNodes(ctx context.Context, repo restic.BlobLoader, root *restic.Node, c
|
||||
|
||||
node.Path = path.Join(root.Path, nodepath)
|
||||
|
||||
if !IsFile(node) && !IsDir(node) && !IsLink(node) {
|
||||
if node.Type != restic.NodeTypeFile && node.Type != restic.NodeTypeDir && node.Type != restic.NodeTypeSymlink {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -176,18 +176,3 @@ func (d *Dumper) writeNode(ctx context.Context, w io.Writer, node *restic.Node)
|
||||
|
||||
return wg.Wait()
|
||||
}
|
||||
|
||||
// IsDir checks if the given node is a directory.
|
||||
func IsDir(node *restic.Node) bool {
|
||||
return node.Type == "dir"
|
||||
}
|
||||
|
||||
// IsLink checks if the given node as a link.
|
||||
func IsLink(node *restic.Node) bool {
|
||||
return node.Type == "symlink"
|
||||
}
|
||||
|
||||
// IsFile checks if the given node is a file.
|
||||
func IsFile(node *restic.Node) bool {
|
||||
return node.Type == "file"
|
||||
}
|
||||
|
||||
@@ -79,16 +79,16 @@ func (d *Dumper) dumpNodeTar(ctx context.Context, node *restic.Node, w *tar.Writ
|
||||
header.Mode |= cISVTX
|
||||
}
|
||||
|
||||
if IsFile(node) {
|
||||
if node.Type == restic.NodeTypeFile {
|
||||
header.Typeflag = tar.TypeReg
|
||||
}
|
||||
|
||||
if IsLink(node) {
|
||||
if node.Type == restic.NodeTypeSymlink {
|
||||
header.Typeflag = tar.TypeSymlink
|
||||
header.Linkname = node.LinkTarget
|
||||
}
|
||||
|
||||
if IsDir(node) {
|
||||
if node.Type == restic.NodeTypeDir {
|
||||
header.Typeflag = tar.TypeDir
|
||||
header.Name += "/"
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func TestFieldTooLong(t *testing.T) {
|
||||
node := restic.Node{
|
||||
Name: "file_with_xattr",
|
||||
Path: "/file_with_xattr",
|
||||
Type: "file",
|
||||
Type: restic.NodeTypeFile,
|
||||
Mode: 0644,
|
||||
ExtendedAttributes: []restic.ExtendedAttribute{
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ func (d *Dumper) dumpNodeZip(ctx context.Context, node *restic.Node, zw *zip.Wri
|
||||
}
|
||||
header.SetMode(node.Mode)
|
||||
|
||||
if IsDir(node) {
|
||||
if node.Type == restic.NodeTypeDir {
|
||||
header.Name += "/"
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (d *Dumper) dumpNodeZip(ctx context.Context, node *restic.Node, zw *zip.Wri
|
||||
return errors.Wrap(err, "ZipHeader")
|
||||
}
|
||||
|
||||
if IsLink(node) {
|
||||
if node.Type == restic.NodeTypeSymlink {
|
||||
if _, err = w.Write([]byte(node.LinkTarget)); err != nil {
|
||||
return errors.Wrap(err, "Write")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user