diff --git a/copyOnWriteFs.go b/copyOnWriteFs.go index f5dd237..e8108a8 100644 --- a/copyOnWriteFs.go +++ b/copyOnWriteFs.go @@ -282,7 +282,8 @@ func (u *CopyOnWriteFs) MkdirAll(name string, perm os.FileMode) error { return u.layer.MkdirAll(name, perm) } if dir { - return ErrFileExists + // This is in line with how os.MkdirAll behaves. + return nil } return u.layer.MkdirAll(name, perm) } diff --git a/copyOnWriteFs_test.go b/copyOnWriteFs_test.go index a6cbc00..94ba725 100644 --- a/copyOnWriteFs_test.go +++ b/copyOnWriteFs_test.go @@ -36,13 +36,12 @@ func TestCopyOnWrite(t *testing.T) { t.Errorf("Mkdir: Got %q for %T", err, fs) } - // https://github.com/spf13/afero/issues/191 - if _, ok := fs.(*OsFs); !ok { - err = fs.MkdirAll(dir, 0744) - if err == nil || !os.IsExist(err) { - t.Errorf("MkdirAll: Got %q for %T", err, fs) - } + // MkdirAll does not return an error when the directory already exists + err = fs.MkdirAll(dir, 0744) + if err != nil { + t.Errorf("MkdirAll: Got %q for %T", err, fs) } + } }