File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,13 +115,31 @@ private void LoadCASCIndices()
115115 return ;
116116
117117 var indexFiles = Directory . GetFiles ( dataDir , "*.idx" ) ;
118+ var highestIndexPerBucket = new Dictionary < byte , int > ( 16 ) ;
119+
118120 foreach ( var indexFile in indexFiles )
119121 {
120122 if ( indexFile . Contains ( "tempfile" ) )
121123 continue ;
122124
123- var indexBucket = Convert . FromHexString ( Path . GetFileNameWithoutExtension ( indexFile ) [ 0 ..2 ] ) [ 0 ] ;
124- CASCIndexInstances . TryAdd ( indexBucket , new CASCIndexInstance ( indexFile ) ) ;
125+ var indexBucket = Convert . ToByte ( Path . GetFileNameWithoutExtension ( indexFile ) [ 0 ..2 ] , 16 ) ;
126+ var indexVersion = Convert . ToInt32 ( Path . GetFileNameWithoutExtension ( indexFile ) [ 2 ..] , 16 ) ;
127+
128+ if ( highestIndexPerBucket . TryGetValue ( indexBucket , out var highestIndex ) )
129+ {
130+ if ( indexVersion > highestIndex )
131+ highestIndexPerBucket [ indexBucket ] = indexVersion ;
132+ }
133+ else
134+ {
135+ highestIndexPerBucket . Add ( indexBucket , indexVersion ) ;
136+ }
137+ }
138+
139+ foreach ( var index in highestIndexPerBucket )
140+ {
141+ var indexFile = Path . Combine ( dataDir , index . Key . ToString ( "x2" ) + index . Value . ToString ( "x2" ) . PadLeft ( 8 , '0' ) + ".idx" ) ;
142+ CASCIndexInstances . Add ( index . Key , new CASCIndexInstance ( indexFile ) ) ;
125143 }
126144
127145 HasLocal = true ;
You can’t perform that action at this time.
0 commit comments