mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-01 05:28:30 +00:00
tar: resolve hardlinks when streaming archive
Fill in the data of the Entry with the data of the file that a hardlink actually represents. Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
parent
ea6c6eff1b
commit
5837d00b07
5 changed files with 108 additions and 1 deletions
17
entry.go
17
entry.go
|
@ -42,6 +42,23 @@ func (e Entry) Descend(filename string) *Entry {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Find is a wrapper around Descend that takes in a whole string path and tries
|
||||
// to find that Entry
|
||||
func (e Entry) Find(filepath string) *Entry {
|
||||
resultnode := &e
|
||||
for _, path := range strings.Split(filepath, "/") {
|
||||
encoded, err := Vis(path)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
resultnode = resultnode.Descend(encoded)
|
||||
if resultnode == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return resultnode
|
||||
}
|
||||
|
||||
// Ascend gets the parent of an Entry. Serves mainly to maintain readability
|
||||
// when traversing up and down an Entry tree
|
||||
func (e Entry) Ascend() *Entry {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue