Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
Merge PR #13 closes #2
Browse files Browse the repository at this point in the history
Support for mkdir calls by creating an empty object with the
directory name and setting appropriate content header.

Signed-off-by: Xavier Lucas <xavier.lucas@corp.ovh.com>
  • Loading branch information
Xavier Lucas committed Feb 16, 2016
1 parent 72ce8a6 commit 049eac8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions svfs/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,29 @@ func (d *Directory) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *f
return nil, fuse.ENOENT
}

func (d *Directory) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error) {
var (
objName = req.Name + "/"
absPath = d.path + objName
)

// Create the file in swift
if err := d.s.ObjectPutBytes(d.c.Name, absPath, nil, "application/directory"); err != nil {
return nil, fuse.EIO
}

// Cache eviction
d.children = []Node{}

// Directory object
return &Directory{
name: req.Name,
path: absPath,
s: d.s,
c: d.c,
}, nil
}

func (d *Directory) Name() string {
return d.name
}
Expand Down Expand Up @@ -213,5 +236,6 @@ var (
_ fs.Node = (*Directory)(nil)
_ fs.NodeCreater = (*Directory)(nil)
_ fs.NodeRemover = (*Directory)(nil)
_ fs.NodeMkdirer = (*Directory)(nil)
_ fs.NodeRenamer = (*Directory)(nil)
)
5 changes: 5 additions & 0 deletions svfs/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func (r *Root) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.C
return nil, nil, fuse.ENOTSUP
}

func (r *Root) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error) {
return nil, fuse.ENOTSUP
}

func (r *Root) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
// TODO : implement container removal
return fuse.ENOTSUP
Expand Down Expand Up @@ -91,6 +95,7 @@ var (
_ Node = (*Root)(nil)
_ fs.Node = (*Root)(nil)
_ fs.NodeCreater = (*Root)(nil)
_ fs.NodeMkdirer = (*Root)(nil)
_ fs.NodeRemover = (*Root)(nil)
_ fs.NodeRenamer = (*Root)(nil)
)

0 comments on commit 049eac8

Please sign in to comment.