Method: DTAS::Mlib#root_node
- Defined in:
- lib/dtas/mlib.rb
#root_node ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/dtas/mlib.rb', line 231 def root_node q = @root_node and return q # root node always has parent_id: 1 q = { parent_id: 1, # self name: '', } node = @db[:nodes][q] if node node[:dirname] = '' @root_node = node return node end begin q[:tlen] = DM_DIR q[:id] = @db[:nodes].insert(q) q rescue Sequel::DatabaseError # we may conflict on insert if we didn't use a transaction raise if @db.in_transaction? @root_node = @db[:paths][q] or raise end end |