Commit 4e9a1e68 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use tombstones correctly for directories that exist in r/o branches.

parent 9c05c7ba
......@@ -264,19 +264,20 @@ func (me *UnionFs) Rmdir(path string) (code fuse.Status) {
if !r.attr.IsDirectory() {
return syscall.ENOTDIR
}
if r.branch > 0 {
stream, code := me.fileSystems[r.branch].OpenDir(path)
if code.Ok() {
_, ok := <-stream
if ok {
// TODO - should consume stream.
return syscall.ENOTEMPTY
}
}
me.putDeletion(path)
return fuse.OK
stream, code := me.OpenDir(path)
found := false
for _ = range stream {
found = true
}
if found {
return syscall.ENOTEMPTY
}
if r.branch > 0 {
code = me.putDeletion(path)
return code
}
code = me.fileSystems[0].Rmdir(path)
if code != fuse.OK {
return code
......
......@@ -449,3 +449,23 @@ func TestTruncateTimestamp(t *testing.T) {
t.Error("timestamp drift", truncTs, fi.Mtime_ns)
}
}
func TestRemoveAll(t *testing.T) {
t.Log("TestRemoveAll")
wd, clean := setupUfs(t)
defer clean()
err := os.Mkdir(wd + "/ro/dir", 0755)
CheckSuccess(err)
contents := "hello"
fn := wd + "/ro/dir/y"
err = ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err)
err = os.RemoveAll(wd+"/mount/dir")
if err != nil {
t.Error("Should delete all")
}
}
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