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) { ...@@ -264,19 +264,20 @@ func (me *UnionFs) Rmdir(path string) (code fuse.Status) {
if !r.attr.IsDirectory() { if !r.attr.IsDirectory() {
return syscall.ENOTDIR return syscall.ENOTDIR
} }
if r.branch > 0 {
stream, code := me.fileSystems[r.branch].OpenDir(path) stream, code := me.OpenDir(path)
if code.Ok() { found := false
_, ok := <-stream for _ = range stream {
if ok { found = true
// TODO - should consume stream. }
return syscall.ENOTEMPTY if found {
} return syscall.ENOTEMPTY
}
me.putDeletion(path)
return fuse.OK
} }
if r.branch > 0 {
code = me.putDeletion(path)
return code
}
code = me.fileSystems[0].Rmdir(path) code = me.fileSystems[0].Rmdir(path)
if code != fuse.OK { if code != fuse.OK {
return code return code
......
...@@ -449,3 +449,23 @@ func TestTruncateTimestamp(t *testing.T) { ...@@ -449,3 +449,23 @@ func TestTruncateTimestamp(t *testing.T) {
t.Error("timestamp drift", truncTs, fi.Mtime_ns) 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