mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
dump: Always dump relative paths into tarballs
Tarballs should only contain relative paths.
This commit is contained in:
parent
d6f739ec22
commit
80a11960dd
@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
@ -65,8 +66,13 @@ func tarTree(ctx context.Context, repo restic.Repository, rootNode *restic.Node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func tarNode(ctx context.Context, tw *tar.Writer, node *restic.Node, repo restic.Repository) error {
|
func tarNode(ctx context.Context, tw *tar.Writer, node *restic.Node, repo restic.Repository) error {
|
||||||
|
relPath, err := filepath.Rel("/", node.Path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
header := &tar.Header{
|
header := &tar.Header{
|
||||||
Name: node.Path,
|
Name: relPath,
|
||||||
Size: int64(node.Size),
|
Size: int64(node.Size),
|
||||||
Mode: int64(node.Mode),
|
Mode: int64(node.Mode),
|
||||||
Uid: int(node.UID),
|
Uid: int(node.UID),
|
||||||
@ -86,7 +92,7 @@ func tarNode(ctx context.Context, tw *tar.Writer, node *restic.Node, repo restic
|
|||||||
header.Typeflag = tar.TypeDir
|
header.Typeflag = tar.TypeDir
|
||||||
}
|
}
|
||||||
|
|
||||||
err := tw.WriteHeader(header)
|
err = tw.WriteHeader(header)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "TarHeader ")
|
return errors.Wrap(err, "TarHeader ")
|
||||||
|
Loading…
Reference in New Issue
Block a user