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 renaming files which share a prefix (e.g foobar.txt and foobar.txt.asc) #73

Open
gildor478 opened this issue Aug 7, 2019 · 0 comments
Labels

Comments

@gildor478
Copy link

Whenever I try to rename files that share the same prefix, I get an error "Received unexpected error: file does not exist" on the second file.

I cannot reproduce the same behavior on osfs, which works as expected in this case.

I expect to be able to rename multiple files in a row even if they have part of their name in common.

Here is a test to reproduce the error:

import (
	"testing"

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

func TestBilly_memfsRename(t *testing.T) {
	mfs := memfs.New()
	fd, err := mfs.Create("/foobar.txt")
	require.NoError(t, err)
	require.NoError(t, fd.Close())
	fd, err = mfs.Create("/barbaz.txt")
	require.NoError(t, err)
	require.NoError(t, fd.Close())
	fd, err = mfs.Create("/foobar.txt.asc")
	require.NoError(t, err)
	require.NoError(t, fd.Close())

	assert.NoError(t, mfs.Rename("/foobar.txt", "foobar-tmp.txt"))
	assert.NoError(t, mfs.Rename("/barbaz.txt", "barbaz-tmp.txt"))
	assert.NoError(t, mfs.Rename("/foobar.txt.asc", "foobar-tmp.txt.asc"))
}
@smola smola added the bug label Aug 21, 2019
@gildor478 gildor478 changed the title memfs doesn't handle renaming file which share a prefix (e.g foobar.txt and foobar.txt.asc) memfs doesn't handle renaming files which share a prefix (e.g foobar.txt and foobar.txt.asc) Nov 29, 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