dump: Use slashes as path separators in tar on windows

This conversion is necessary as paths returned by filepath.Rel use the
operating-system native path separator
This commit is contained in:
Michael Eischer 2020-08-30 18:15:51 +02:00
parent bcf44a9c3f
commit dcf9ded977
2 changed files with 4 additions and 3 deletions

View File

@ -72,7 +72,7 @@ func tarNode(ctx context.Context, tw *tar.Writer, node *restic.Node, repo restic
}
header := &tar.Header{
Name: relPath,
Name: filepath.ToSlash(relPath),
Size: int64(node.Size),
Mode: int64(node.Mode),
Uid: int(node.UID),

View File

@ -147,8 +147,9 @@ func checkTar(t *testing.T, testDir string, srcTar *bytes.Buffer) error {
continue
}
if filepath.Base(hdr.Name) != match.Name() {
return fmt.Errorf("foldernames don't match got %v want %v", filepath.Base(hdr.Name), match.Name())
filebase := filepath.ToSlash(match.Name())
if filepath.Base(hdr.Name) != filebase {
return fmt.Errorf("foldernames don't match got %v want %v", filepath.Base(hdr.Name), filebase)
}
} else {