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

Commit

Permalink
Handle rmdir(2) resolves #82
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Lucas <[email protected]>
  • Loading branch information
Xavier Lucas committed Aug 3, 2016
1 parent fbb978b commit bddc4b8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
26 changes: 25 additions & 1 deletion svfs/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ func (d *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
)

if directory, ok := node.(*Directory); ok {
empty, err := directory.isEmpty()
if err != nil {
return err
}
if !empty {
return fuse.ENOTEMPTY
}
return d.removeDirectory(directory, req.Name)
}
if object, ok := node.(*Object); ok {
Expand All @@ -307,9 +314,26 @@ func (d *Directory) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp
return nil
}

func (d *Directory) isEmpty() (bool, error) {
// Fetch objects
objects, err := SwiftConnection.ObjectsAll(d.c.Name, &swift.ObjectsOpts{
Delimiter: '/',
Prefix: d.path,
Limit: 2,
})
if err != nil {
return false, err
}
for _, object := range objects {
if object.Name != d.path {
return false, nil
}
}
return true, nil
}

func (d *Directory) move(oldContainer, oldPath, oldName, newContainer, newPath, newName string) error {
// Get the old node from cache

return fuse.ENOTSUP
}

Expand Down
22 changes: 12 additions & 10 deletions vendor/bazil.org/fuse/fuse.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bddc4b8

Please sign in to comment.