@@ -17,7 +17,7 @@ public async Task<UpdateCorpusResponse> HandleAsync(UpdateCorpus request, Cancel
1717 {
1818 await corpora . CheckOwnerAsync ( request . CorpusId , request . Owner , cancellationToken ) ;
1919
20- IReadOnlyList < CorpusFile > files = await MapFilesAsync ( request . Files , cancellationToken ) ;
20+ IReadOnlyList < CorpusFile > files = await MapFilesAsync ( request . Owner , request . Files , cancellationToken ) ;
2121
2222 Corpus corpus = await dataAccessContext . WithTransactionAsync (
2323 async ct =>
@@ -29,7 +29,7 @@ public async Task<UpdateCorpusResponse> HandleAsync(UpdateCorpus request, Cancel
2929 ) ;
3030 if ( updated is null )
3131 throw new EntityNotFoundException ( $ "Could not find the Corpus '{ request . CorpusId } '.") ;
32- HashSet < string > corpusFileIds = updated . Files . Select ( f => f . FileRef ) . ToHashSet ( ) ;
32+ HashSet < string > corpusFileIds = [ .. updated . Files . Select ( f => f . FileRef ) ] ;
3333 IDictionary < string , DataFile > corpusDataFilesDict = (
3434 await dataFiles . GetAllAsync ( f => corpusFileIds . Contains ( f . Id ) , ct )
3535 ) . ToDictionary ( f => f . Id ) ;
@@ -54,14 +54,18 @@ await eventRouter.PublishAsync(
5454 }
5555
5656 private async Task < IReadOnlyList < CorpusFile > > MapFilesAsync (
57+ string owner ,
5758 IReadOnlyList < CorpusFileConfigDto > files ,
5859 CancellationToken cancellationToken
5960 )
6061 {
6162 var corpusFiles = new List < CorpusFile > ( ) ;
6263 foreach ( CorpusFileConfigDto file in files )
6364 {
64- DataFile ? dataFile = await dataFiles . GetAsync ( file . FileId , cancellationToken ) ;
65+ DataFile ? dataFile = await dataFiles . GetAsync (
66+ e => e . Id == file . FileId && e . Owner == owner ,
67+ cancellationToken
68+ ) ;
6569 if ( dataFile is null )
6670 throw new EntityNotFoundException ( $ "Could not find the DataFile '{ file . FileId } '.") ;
6771 corpusFiles . Add ( new CorpusFile { FileRef = file . FileId , TextId = file . TextId } ) ;
0 commit comments