Attempts to get file writes working properly again

This commit is contained in:
Alex Yatskov 2015-06-19 19:40:25 +09:00
parent aeb0822714
commit ec4e931f68
2 changed files with 5 additions and 4 deletions

2
dir.go
View File

@ -95,7 +95,7 @@ func (vd *verDir) createFile(name string, flags fuse.OpenFlags) (*verFile, *verF
node := newVerNode(childPath, vd.node.ver, nil, NodeFlagVer) node := newVerNode(childPath, vd.node.ver, nil, NodeFlagVer)
file := newVerFile(node, vd) file := newVerFile(node, vd)
handle, err := file.open(flags) handle, err := file.open(flags, true)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -62,14 +62,15 @@ func (vf *verFile) version() error {
return nil return nil
} }
func (vf *verFile) open(flags fuse.OpenFlags) (*verFileHandle, error) { func (vf *verFile) open(flags fuse.OpenFlags, create bool) (*verFileHandle, error) {
if !flags.IsReadOnly() { if !create && !flags.IsReadOnly() {
if err := vf.version(); err != nil { if err := vf.version(); err != nil {
return nil, err return nil, err
} }
} }
path := vf.node.rebasedPath() path := vf.node.rebasedPath()
handle, err := os.OpenFile(path, int(flags), 0644) handle, err := os.OpenFile(path, int(flags), 0644)
if err != nil { if err != nil {
return nil, err return nil, err
@ -105,7 +106,7 @@ func (vf *verFile) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *
// NodeOpener // NodeOpener
func (vf *verFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { func (vf *verFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
handle, err := vf.open(req.Flags) handle, err := vf.open(req.Flags, false)
if err != nil { if err != nil {
return nil, err return nil, err
} }