From 2cd8a44b38e36b09dc4bff00248a7eea81b08f23 Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Sun, 24 Jan 2016 07:56:32 +0100 Subject: [PATCH] fix isBaseFile --- copyOnWriteFs.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/copyOnWriteFs.go b/copyOnWriteFs.go index 0738c72..e4572dd 100644 --- a/copyOnWriteFs.go +++ b/copyOnWriteFs.go @@ -30,6 +30,16 @@ func (u *CopyOnWriteFs) isBaseFile(name string) (bool, error) { return false, nil } _, err := u.base.Stat(name) + if err != nil { + if oerr, ok := err.(*os.PathError); ok { + if oerr.Err == os.ErrNotExist || oerr.Err == syscall.ENOENT { + return false, nil + } + } + if err == syscall.ENOENT { + return false, nil + } + } return true, err } @@ -216,5 +226,5 @@ func (u *CopyOnWriteFs) MkdirAll(name string, perm os.FileMode) error { } func (u *CopyOnWriteFs) Create(name string) (File, error) { - return u.OpenFile(name, os.O_TRUNC|os.O_RDWR, 0666) + return u.OpenFile(name, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0666) }