Skip to content

Commit

Permalink
etcdserver: Check whether node is a directory
Browse files Browse the repository at this point in the history
If dir=true and prevExist=true PUT only if the target node is a
directory. Otherwise return "Not a directory".

Addresses etcd-io#518 on github.
  • Loading branch information
iankronquist committed Jan 25, 2015
1 parent ab27cb3 commit aaa7712
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"time"

"github.com/coreos/etcd/discovery"
etcdErr "github.com/coreos/etcd/error"
"github.com/coreos/etcd/etcdserver/etcdhttp/httptypes"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/coreos/etcd/etcdserver/stats"
Expand Down Expand Up @@ -695,6 +696,9 @@ func (s *EtcdServer) applyRequest(r pb.Request) Response {
switch {
case existsSet:
if exists {
if r.Dir && !s.store.IsKeyDir(r.Path) {
return f(nil, etcdErr.NewError(etcdErr.EcodeNotDir, r.Path, s.store.Index()))
}
return f(s.store.Update(r.Path, r.Val, expr))
}
return f(s.store.Create(r.Path, r.Dir, r.Val, false, expr))
Expand Down

0 comments on commit aaa7712

Please sign in to comment.