Commit 25145ebb authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

UnionFs: stop leaking R/O files into directory when doing (Rename a b,

Mkdir a)
parent 90981c86
......@@ -347,6 +347,15 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
}
me.branchCache.Set(path, branchResult{attr, fuse.OK, 0})
}
var stream chan fuse.DirEntry
stream, code = me.OpenDir(path)
if code.Ok() {
for entry := range stream {
me.putDeletion(filepath.Join(path, entry.Name))
}
}
return code
}
......
......@@ -446,6 +446,10 @@ func TestRenameDirBasic(t *testing.T) {
if err != nil || len(entries) != 1 || entries[0].Name != "subdir" {
t.Errorf("readdir(%s/mount/renamed) should have one entry: %v, err %v", wd, entries, err)
}
if err = os.Mkdir(wd + "/mount/dir", 0755); err != nil {
t.Errorf("mkdir should succeed %v", err)
}
}
func TestRenameDirWithDeletions(t *testing.T) {
......@@ -486,6 +490,14 @@ func TestRenameDirWithDeletions(t *testing.T) {
if fi, _ := os.Lstat(wd + "/mount/renamed/file.txt"); fi != nil {
t.Fatalf("%s/mount/renamed/file.txt should have disappeared %#v", wd, fi)
}
if err = os.Mkdir(wd + "/mount/dir", 0755); err != nil {
t.Errorf("mkdir should succeed %v", err)
}
if fi, _ := os.Lstat(wd + "/mount/dir/subdir"); fi != nil {
t.Fatalf("%s/mount/dir/subdir should have disappeared %#v", wd, fi)
}
}
func TestRenameSymlink(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment