Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memfs doesn't handle creating and opening files in directory which is a symlink #72

Open
gildor478 opened this issue Jul 12, 2019 · 0 comments
Labels

Comments

@gildor478
Copy link

Whenever I create a symlink to a directory, I cannot create/open files using this symlink. It works perfectly, if I use "osfs".

Here is a test for this bug:

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"gopkg.in/src-d/go-billy.v4/memfs"
	"gopkg.in/src-d/go-billy.v4/util"
)

func TestSymlink_Mkdir(t *testing.T) {
	fs := memfs.New()
	//fs := osfs.New("/tmp")
	require.NoError(t, fs.MkdirAll("dir", 0755))
	require.NoError(t, util.WriteFile(fs, "dir/file.txt", nil, 0644))
	require.NoError(t, fs.Symlink("dir", "link"))

	_, err := fs.Stat("dir/file.txt")
	assert.NoError(t, err, "reading directly /dir/file.txt")
	_, err = fs.Stat("link/file.txt")
	assert.NoError(t, err, "reading /dir/file.txt through /link")

	fd, err := fs.Create("link/file2.txt")
	assert.NoError(t, err)
	assert.NoError(t, fd.Close())
	_, err = fs.Stat("dir/file2.txt")
	assert.NoError(t, err, "reading file2.txt created into the /link")
}

Let me know if I have made a mistake.

@smola smola added the bug label Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants