File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
experiments/odb-redesign/src Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,8 @@ mod odb {
183183 }
184184 }
185185
186+ /// We do it like this as we first have to check for a loaded interior in read-only mode, and then upgrade
187+ /// when we know that loading is necessary. This also works around borrow check, which is a nice coincidence.
186188 pub fn do_load ( & mut self , load : impl FnOnce ( & Path ) -> io:: Result < T > ) -> io:: Result < Option < & T > > {
187189 use OnDiskFileState :: * ;
188190 match & mut self . state {
@@ -468,22 +470,25 @@ mod odb {
468470 policy:: IndexAndPacks :: Index ( bundle) => Ok ( bundle
469471 . data
470472 . do_load ( |path| {
471- Ok ( features :: OwnShared :: new ( git_pack:: data:: File :: at ( path) . map_err (
473+ git_pack:: data:: File :: at ( path) . map ( features :: OwnShared :: new ) . map_err (
472474 |err| match err {
473475 git_odb:: data:: header:: decode:: Error :: Io { source, .. } => {
474476 source
475477 }
476478 other => std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , other) ,
477479 } ,
478- ) ? ) )
480+ )
479481 } ) ?
480482 . cloned ( ) ) ,
481483 _ => unreachable ! ( ) ,
482484 }
483485 }
484486 } ,
487+ // This can also happen if they use an old index into our new and refreshed data which might have a multi-index
488+ // here.
485489 policy:: IndexAndPacks :: MultiIndex ( _) => Ok ( None ) ,
486490 } ,
491+ // This can happen if we condense our data, returning None tells the caller to refresh their indices
487492 None => Ok ( None ) ,
488493 }
489494 }
You can’t perform that action at this time.
0 commit comments