mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #737 from ghodss/fix-dir-ttl-response
fix(store.go) include node.dir = true when updating a directory's ttl
This commit is contained in:
@@ -432,9 +432,13 @@ func (s *store) Update(nodePath string, newValue string, expireTime time.Time) (
|
||||
|
||||
n.Write(newValue, nextIndex)
|
||||
|
||||
// copy the value for safety
|
||||
newValueCopy := ustrings.Clone(newValue)
|
||||
eNode.Value = &newValueCopy
|
||||
if n.IsDir() {
|
||||
eNode.Dir = true
|
||||
} else {
|
||||
// copy the value for safety
|
||||
newValueCopy := ustrings.Clone(newValue)
|
||||
eNode.Value = &newValueCopy
|
||||
}
|
||||
|
||||
// update ttl
|
||||
n.UpdateTTL(expireTime)
|
||||
|
||||
@@ -287,8 +287,9 @@ func TestStoreUpdateDirTTL(t *testing.T) {
|
||||
|
||||
s.Create("/foo", true, "", false, Permanent)
|
||||
s.Create("/foo/bar", false, "baz", false, Permanent)
|
||||
_, err := s.Update("/foo", "", time.Now().Add(500*time.Millisecond))
|
||||
e, _ := s.Get("/foo/bar", false, false)
|
||||
e, err := s.Update("/foo", "", time.Now().Add(500*time.Millisecond))
|
||||
assert.Equal(t, e.Node.Dir, true, "")
|
||||
e, _ = s.Get("/foo/bar", false, false)
|
||||
assert.Equal(t, *e.Node.Value, "baz", "")
|
||||
|
||||
time.Sleep(600 * time.Millisecond)
|
||||
|
||||
Reference in New Issue
Block a user