@@ -161,6 +161,13 @@ impl DirectoryLayer {
161
161
162
162
node. load_metadata ( & trx) . await ?;
163
163
164
+ println ! (
165
+ "node under path {:?} exists ? {}, layer = {:?}" ,
166
+ node. current_path,
167
+ node. exists( ) ,
168
+ node. layer
169
+ ) ;
170
+
164
171
if !node. exists ( ) || node. layer . eq ( PARTITION_LAYER ) {
165
172
return Ok ( node) ;
166
173
}
@@ -231,6 +238,7 @@ impl DirectoryLayer {
231
238
}
232
239
233
240
let node = self . find ( trx, path. to_owned ( ) ) . await ?;
241
+ println ! ( "node exists? {}" , node. exists( ) ) ;
234
242
235
243
if node. exists ( ) {
236
244
if node. is_in_partition ( false ) {
@@ -240,12 +248,24 @@ impl DirectoryLayer {
240
248
None => unreachable ! ( "node's subspace is not set" ) ,
241
249
Some ( s) => s,
242
250
} ;
243
- let dir_space =
244
- self . contents_of_node ( subspace_node, node. current_path , node. layer ) ?;
245
- dir_space
246
- . create_or_open ( trx, sub_path. to_owned ( ) , prefix, layer)
247
- . await ?;
248
- Ok ( dir_space)
251
+ match self . contents_of_node ( subspace_node, node. current_path , node. layer ) ? {
252
+ DirectoryOutput :: DirectorySubspace ( _) => unreachable ! ( "already in partition" ) ,
253
+ DirectoryOutput :: DirectoryPartition ( directory_partition) => {
254
+ let dir_space = directory_partition
255
+ . directory_subspace
256
+ . directory_layer
257
+ . create_or_open_internal (
258
+ trx,
259
+ sub_path. to_owned ( ) ,
260
+ prefix,
261
+ layer,
262
+ allow_create,
263
+ allow_open,
264
+ )
265
+ . await ?;
266
+ Ok ( dir_space)
267
+ }
268
+ }
249
269
} else {
250
270
self . open_internal ( layer, & node, allow_open) . await
251
271
}
0 commit comments