@@ -28,6 +28,8 @@ public CommitDetailSharedData()
2828
2929 public partial class CommitDetail : ObservableObject , IDisposable
3030 {
31+ private const int MaxOFPASampleSize = 256 * 1024 ;
32+
3133 public Repository Repository
3234 {
3335 get => _repo ;
@@ -693,30 +695,32 @@ private async Task DecodeOFPAPathsAsync(List<Models.Change> changes)
693695
694696 await Task . Run ( async ( ) =>
695697 {
696- var objectSpecs = new List < ( string RelativePath , string Spec ) > ( ) ;
698+ var filesToDecode = new List < ( string RelativePath , string Spec ) > ( ) ;
697699 foreach ( var change in changes )
698700 {
699701 if ( Utilities . OFPAParser . IsOFPAFile ( change . Path ) )
700702 {
701- // For deleted files, read from parent. For others, read from current commit.
703+ // Use heuristic to determine revision:
704+ // - Deleted files (WorkTree or Index) -> fetch from Parent commit.
705+ // - Added/Modified files -> fetch from Current commit.
702706 var spec = ( change . WorkTree == Models . ChangeState . Deleted || change . Index == Models . ChangeState . Deleted )
703707 ? $ "{ parent } :{ change . Path } "
704708 : $ "{ _commit . SHA } :{ change . Path } ";
705- objectSpecs . Add ( ( change . Path , spec ) ) ;
709+ filesToDecode . Add ( ( change . Path , spec ) ) ;
706710 }
707711 }
708712
709- if ( objectSpecs . Count == 0 )
713+ if ( filesToDecode . Count == 0 )
710714 return ;
711715
712- var specs = new List < string > ( ) ;
713- foreach ( var entry in objectSpecs )
714- specs . Add ( entry . Spec ) ;
716+ var batchRequests = new List < string > ( ) ;
717+ foreach ( var entry in filesToDecode )
718+ batchRequests . Add ( entry . Spec ) ;
715719
716- var dataMap = await Commands . QueryFileContent . RunBatchAsync ( repositoryPath , specs , MaxOFPASampleSize ) . ConfigureAwait ( false ) ;
717- foreach ( var entry in objectSpecs )
720+ var batchResults = await Commands . QueryFileContent . RunBatchAsync ( repositoryPath , batchRequests , MaxOFPASampleSize ) . ConfigureAwait ( false ) ;
721+ foreach ( var entry in filesToDecode )
718722 {
719- if ( dataMap . TryGetValue ( entry . Spec , out var data ) )
723+ if ( batchResults . TryGetValue ( entry . Spec , out var data ) )
720724 {
721725 var decoded = Utilities . OFPAParser . DecodeFromData ( data ) ;
722726 results [ entry . RelativePath ] = decoded ? . LabelValue ;
@@ -763,6 +767,5 @@ await Dispatcher.UIThread.InvokeAsync(() =>
763767 private Vector _scrollOffset = Vector . Zero ;
764768 private Dictionary < string , string > _decodedPaths = null ;
765769 private Task _currentDecodeTask = Task . CompletedTask ;
766- private const int MaxOFPASampleSize = 256 * 1024 ;
767770 }
768771}
0 commit comments