MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / create

Method create

cmd/cql-fuse/fs.go:93–108  ·  view source on GitHub ↗

create inserts a new node. parentID: inode ID of the parent directory. name: name of the new node node: new node.

(ctx context.Context, parentID uint64, name string, node *Node)

Source from the content-addressed store, hash-verified

91// name: name of the new node
92// node: new node.
93func (cfs CFS) create(ctx context.Context, parentID uint64, name string, node *Node) error {
94 inode := node.toJSON()
95 const insertNode = `INSERT INTO fs_inode VALUES (?, ?)`
96 const insertNamespace = `INSERT INTO fs_namespace VALUES (?, ?, ?)`
97
98 err := client.ExecuteTx(ctx, cfs.db, nil /* txopts */, func(tx *sql.Tx) error {
99 if _, err := tx.Exec(insertNode, node.ID, inode); err != nil {
100 return err
101 }
102 if _, err := tx.Exec(insertNamespace, parentID, name, node.ID); err != nil {
103 return err
104 }
105 return nil
106 })
107 return err
108}
109
110// remove removes a node give its name and its parent ID.
111// If 'checkChildren' is true, fails if the node has children.

Callers 3

MkdirMethod · 0.80
CreateMethod · 0.80
SymlinkMethod · 0.80

Calls 3

ExecuteTxFunction · 0.92
toJSONMethod · 0.80
ExecMethod · 0.65

Tested by

no test coverage detected