From beda3674339347927cecd2e7a27d34c5e7d886f1 Mon Sep 17 00:00:00 2001 From: paul gruenbacher Date: Mon, 18 Apr 2016 19:25:52 -0400 Subject: [PATCH 1/2] test to replicate stat error --- copyOnWriteFs_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 copyOnWriteFs_test.go diff --git a/copyOnWriteFs_test.go b/copyOnWriteFs_test.go new file mode 100644 index 0000000..2a00fab --- /dev/null +++ b/copyOnWriteFs_test.go @@ -0,0 +1,23 @@ +package afero + +import "testing" + +func TestCopyOnWrite(t *testing.T) { + var fs Fs + var err error + base := NewOsFs() + roBase := NewReadOnlyFs(base) + ufs := NewCopyOnWriteFs(roBase, NewMemMapFs()) + fs = ufs + err = fs.MkdirAll("nonexistent/directory/", 0744) + if err != nil { + t.Error(err) + return + } + _, err = fs.Create("nonexistent/directory/newfile") + if err != nil { + t.Error(err) + return + } + +} From 8404a5e8bf7356c96ef9ca6bc894d4fae15dd881 Mon Sep 17 00:00:00 2001 From: Martin Bertschler Date: Wed, 20 Apr 2016 14:30:10 +0200 Subject: [PATCH 2/2] don't return error in CopyOnWriteFs OpenFile if it is a not exist error fixes #78 --- copyOnWriteFs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/copyOnWriteFs.go b/copyOnWriteFs.go index 039ce53..fa0c936 100644 --- a/copyOnWriteFs.go +++ b/copyOnWriteFs.go @@ -1,11 +1,11 @@ package afero import ( + "fmt" "os" "path/filepath" "syscall" "time" - "fmt" ) // The CopyOnWriteFs is a union filesystem: a read only base file system with @@ -147,7 +147,7 @@ func (u *CopyOnWriteFs) OpenFile(name string, flag int, perm os.FileMode) (File, dir := filepath.Dir(name) isaDir, err := IsDir(u.base, dir) - if err != nil { + if err != nil && !os.IsNotExist(err) { return nil, err } if isaDir {