Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Untar: Fixing symlink untarring in memfs (#288)
Browse files Browse the repository at this point in the history
* Untar: Fixing symlink untarring in memfs

* Fixed unit tests

* Fixed typo
  • Loading branch information
apourchet committed Oct 31, 2019
1 parent 1bacf2a commit c28fc3a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions lib/snapshot/mem_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,6 @@ func (fs *MemFS) untarDirectory(path string, header *tar.Header) error {
// untarSymlink creates the symlink specified by header at path.
func (fs *MemFS) untarSymlink(path string, header *tar.Header) error {
target := header.Linkname
if filepath.IsAbs(header.Linkname) {
target = filepath.Join(fs.tree.src, target)
}
if err := os.Symlink(target, path); err != nil {
return fmt.Errorf("create symlink %s => %s: %s", path, target, err)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/snapshot/mem_fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ func TestUntarFromPath(t *testing.T) {
require.NoError(err)
require.False(fi.IsDir())

contents, err = ioutil.ReadFile(filepath.Join(tmpRoot, "mydir"))
target, err := os.Readlink(filepath.Join(tmpRoot, "mydir"))
require.NoError(err)
require.Equal([]byte("TARGET"), contents)
require.Equal("/target.txt", target)

require.Equal(7, fs.layers[len(fs.layers)-1].count())

Expand Down

0 comments on commit c28fc3a

Please sign in to comment.