data: split node and snapshot code from restic package

This commit is contained in:
Michael Eischer
2025-09-23 20:01:09 +02:00
parent c85b157e0e
commit 56ac8360c7
166 changed files with 1170 additions and 1107 deletions

View File

@@ -12,8 +12,8 @@ import (
"syscall"
"testing"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test"
)
@@ -30,7 +30,7 @@ func stat(t testing.TB, filename string) (fi os.FileInfo, ok bool) {
return fi, true
}
func checkFile(t testing.TB, fi fs.FileInfo, node *restic.Node) {
func checkFile(t testing.TB, fi fs.FileInfo, node *data.Node) {
t.Helper()
stat := fi.Sys().(*syscall.Stat_t)
@@ -47,7 +47,7 @@ func checkFile(t testing.TB, fi fs.FileInfo, node *restic.Node) {
t.Errorf("Dev does not match, want %v, got %v", stat.Dev, node.DeviceID)
}
if node.Size != uint64(stat.Size) && node.Type != restic.NodeTypeSymlink {
if node.Size != uint64(stat.Size) && node.Type != data.NodeTypeSymlink {
t.Errorf("Size does not match, want %v, got %v", stat.Size, node.Size)
}
@@ -76,7 +76,7 @@ func checkFile(t testing.TB, fi fs.FileInfo, node *restic.Node) {
}
}
func checkDevice(t testing.TB, fi fs.FileInfo, node *restic.Node) {
func checkDevice(t testing.TB, fi fs.FileInfo, node *data.Node) {
stat := fi.Sys().(*syscall.Stat_t)
if node.Device != uint64(stat.Rdev) {
t.Errorf("Rdev does not match, want %v, got %v", stat.Rdev, node.Device)
@@ -124,9 +124,9 @@ func TestNodeFromFileInfo(t *testing.T) {
rtest.OK(t, err)
switch node.Type {
case restic.NodeTypeFile, restic.NodeTypeSymlink:
case data.NodeTypeFile, data.NodeTypeSymlink:
checkFile(t, fi, node)
case restic.NodeTypeDev, restic.NodeTypeCharDev:
case data.NodeTypeDev, data.NodeTypeCharDev:
checkFile(t, fi, node)
checkDevice(t, fi, node)
default: