getInode looks up an inode given its name and its parent ID. If not found, error will be sql.ErrNoRows.
(e sqlExecutor, parentID uint64, name string)
| 52 | // getInode looks up an inode given its name and its parent ID. |
| 53 | // If not found, error will be sql.ErrNoRows. |
| 54 | func getInode(e sqlExecutor, parentID uint64, name string) (*Node, error) { |
| 55 | var raw string |
| 56 | const sql = `SELECT inode FROM fs_inode WHERE id = |
| 57 | (SELECT id FROM fs_namespace WHERE (parentID, name) = (?, ?))` |
| 58 | if err := e.QueryRow(sql, parentID, name).Scan(&raw); err != nil { |
| 59 | return nil, err |
| 60 | } |
| 61 | |
| 62 | node := &Node{} |
| 63 | err := json.Unmarshal([]byte(raw), node) |
| 64 | return node, err |
| 65 | } |
| 66 | |
| 67 | // checkIsEmpty returns nil if 'id' has no children. |
| 68 | func checkIsEmpty(e sqlExecutor, id uint64) error { |