tsuru/tsuru

RecordingFs.Rename() does not work for directories content

tcarreira opened this issue · 0 comments

Description

A clear and concise description of what the bug is.

The RecordingFs.Rename() only works for specific files.
When trying to rename a directory (expecting its content to be available on the newer path), only the directory is renamed. Every file inside it will remain on the old path.

Steps to reproduce

func main()
	fs := fstest.RecordingFs{}
	fs.Mkdir("/tmp/dir1", 0755)
	fs.Create("/tmp/dir1/file1")
	fs.Create("/tmp/dir1/file2")
	for _, fname := range []string{"/tmp/dir1", "/tmp/dir1/file1", "/tmp/dir1/file2"} {
		_, err := fs.Stat(fname)
		assert(err == nil, fmt.Sprintf("%s should exist", fname))
	}

	fs.Rename("/tmp/dir1", "/tmp/dir2")
	for _, fname := range []string{"/tmp/dir2", "/tmp/dir2/file1", "/tmp/dir2/file2"} {
		_, err := fs.Stat(fname)
		assert(err == nil, fmt.Sprintf("%s should exist", fname))
	}
}

// go run main.go
//   assertion failed! /tmp/dir2/file1 should exist
//   assertion failed! /tmp/dir2/file2 should exist

Expected result

A clear and concise description of what you expected to happen.

When renaming (moving) a directory, every child should me renamed (moved) as well