MCPcopy
hub / github.com/CodisLabs/codis / mkdir

Method mkdir

pkg/models/zk/zkclient.go:163–186  ·  view source on GitHub ↗
(conn *zk.Conn, path string)

Source from the content-addressed store, hash-verified

161}
162
163func (c *Client) mkdir(conn *zk.Conn, path string) error {
164 if path == "" || path == "/" {
165 return nil
166 }
167 if exists, _, err := conn.Exists(path); err != nil {
168 return errors.Trace(err)
169 } else if exists {
170 return nil
171 }
172 if err := c.mkdir(conn, filepath.Dir(path)); err != nil {
173 return err
174 }
175 _, err := conn.Create(path, []byte{}, 0, func() []zk.ACL {
176 const perm = zk.PermAll
177 if c.username != "" {
178 return zk.DigestACL(perm, c.username, c.password)
179 }
180 return zk.WorldACL(perm)
181 }())
182 if err != nil && errors.NotEqual(err, zk.ErrNodeExists) {
183 return errors.Trace(err)
184 }
185 return nil
186}
187
188func (c *Client) Create(path string, data []byte) error {
189 c.Lock()

Callers 2

MkdirMethod · 0.95
createMethod · 0.95

Calls 1

CreateMethod · 0.65

Tested by

no test coverage detected