@@ -14,6 +14,7 @@ public class TVFSInstance : IRootInstance
1414 private readonly Dictionary < string , FileSpan > rootManifestEntries = [ ] ;
1515 private readonly ConcurrentDictionary < uint , RootEntry > entriesFDID = [ ] ;
1616 private readonly ConcurrentDictionary < uint , List < RootEntry > > entriesFDIDFull = [ ] ;
17+ private readonly Lock entryLock = new Lock ( ) ;
1718
1819 private LoadMode loadedWith ;
1920
@@ -386,22 +387,27 @@ private void RecordFile(string path, FileSpan[] spans, int contentFlags, int loc
386387 return ;
387388 }
388389
389- if ( loadedWith == LoadMode . Full )
390- {
391- if ( ! entriesFDIDFull . TryGetValue ( generic . FileDataId , out var list ) )
392- entriesFDIDFull [ generic . FileDataId ] = list = new List < RootEntry > ( ) ;
393390
394- foreach ( var span in spans )
391+
392+ if ( loadedWith == LoadMode . Full )
393+ {
394+ lock ( entryLock )
395395 {
396- var entry = new RootEntry
397- {
398- fileDataID = generic . FileDataId ,
399- md5 = new MD5 ( generic . CKey ) ,
400- localeFlags = ( LocaleFlags ) localeFlags ,
401- contentFlags = ( ContentFlags ) contentFlags ,
402- } ;
396+ if ( ! entriesFDIDFull . TryGetValue ( generic . FileDataId , out var list ) )
397+ entriesFDIDFull [ generic . FileDataId ] = list = new List < RootEntry > ( ) ;
403398
404- list . Add ( entry ) ;
399+ foreach ( var span in spans )
400+ {
401+ var entry = new RootEntry
402+ {
403+ fileDataID = generic . FileDataId ,
404+ md5 = new MD5 ( generic . CKey ) ,
405+ localeFlags = ( LocaleFlags ) localeFlags ,
406+ contentFlags = ( ContentFlags ) contentFlags ,
407+ } ;
408+
409+ list . Add ( entry ) ;
410+ }
405411 }
406412 }
407413 else
@@ -414,7 +420,8 @@ private void RecordFile(string path, FileSpan[] spans, int contentFlags, int loc
414420 contentFlags = ( ContentFlags ) contentFlags ,
415421 } ;
416422
417- entriesFDID . TryAdd ( generic . FileDataId , entry ) ;
423+ lock ( entryLock )
424+ entriesFDID . TryAdd ( generic . FileDataId , entry ) ;
418425 }
419426 }
420427
0 commit comments