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

Commit

Permalink
Revert "Untar: Fixing symlink untarring in memfs (#288)" (#293)
Browse files Browse the repository at this point in the history
This reverts commit c28fc3a.
  • Loading branch information
Yiran Wang authored Dec 5, 2019
1 parent d419d01 commit 13ff85b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/snapshot/mem_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ 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())

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

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

Expand Down

0 comments on commit 13ff85b

Please sign in to comment.