forked from mirror/afero
Merge branch with fix for OpenFile behaviour in CopyOnWriteFs'
This commit is contained in:
commit
12baa8a6f2
|
@ -1,11 +1,11 @@
|
||||||
package afero
|
package afero
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The CopyOnWriteFs is a union filesystem: a read only base file system with
|
// 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)
|
dir := filepath.Dir(name)
|
||||||
isaDir, err := IsDir(u.base, dir)
|
isaDir, err := IsDir(u.base, dir)
|
||||||
if err != nil {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if isaDir {
|
if isaDir {
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue