@@ -34,20 +34,20 @@ namespace UnifiedUpdatePlatform.Services.WindowsUpdate.Downloads
3434{
3535public static class UpdateUtils
3636{
37- public static string GetFilenameForCEUIFile ( CExtendedUpdateInfoXml . File file2 , IEnumerable < CompDBXmlClass . PayloadItem > payloadItems )
37+ public static string [ ] GetFilenameForCEUIFile ( CExtendedUpdateInfoXml . File file2 , IEnumerable < CompDBXmlClass . PayloadItem > payloadItems )
3838{
3939string filename = file2 . FileName . Replace ( '\\ ' , Path . DirectorySeparatorChar ) ;
4040if ( payloadItems . Any ( x=> x . PayloadHash == file2 . AdditionalDigest . Text || x . PayloadHash == file2 . Digest ) )
4141{
42- CompDBXmlClass . PayloadItem payload = payloadItems . First ( x=> x . PayloadHash == file2 . AdditionalDigest . Text || x . PayloadHash == file2 . Digest ) ;
43- return payload . Path . Replace ( '\\ ' , Path . DirectorySeparatorChar ) ;
42+ IEnumerable < CompDBXmlClass . PayloadItem > payloads = payloadItems . Where ( x=> x . PayloadHash == file2 . AdditionalDigest . Text || x . PayloadHash == file2 . Digest ) ;
43+ return payloads . Select ( p => p . Path . Replace ( '\\ ' , Path . DirectorySeparatorChar ) ) . ToArray ( ) ;
4444}
4545else if ( ! payloadItems . Any ( ) && filename . Contains ( '_' ) && ! filename . StartsWith ( "_" ) && ( ! filename . Contains ( '-' ) || filename . IndexOf ( '-' ) > filename . IndexOf ( '_' ) ) )
4646{
4747filename = filename [ ..filename . IndexOf ( '_' ) ] + Path . DirectorySeparatorChar + filename [ ( filename . IndexOf ( '_' ) + 1 ) ..] ;
48- return filename . TrimStart ( Path . DirectorySeparatorChar ) ;
48+ return new string [ ] { filename . TrimStart ( Path . DirectorySeparatorChar ) } ;
4949}
50- return filename ;
50+ return new string [ ] { filename } ;
5151}
5252
5353public static bool ShouldFileGetDownloaded ( CExtendedUpdateInfoXml . File file2 , IEnumerable < CompDBXmlClass . PayloadItem > payloadItems )
@@ -192,7 +192,7 @@ private static
192192
193193foreach ( CompDBXmlClass . CompDB cdb in selectedCompDBs )
194194{
195- if ( cdb == AppCompDBs || cdb . Packages == null )
195+ if ( AppCompDBs . Contains ( cdb ) || cdb . Packages == null )
196196{
197197continue ;
198198}
@@ -233,7 +233,7 @@ private static
233233
234234foreach ( CompDBXmlClass . CompDB cdb in discardedCompDBs )
235235{
236- if ( cdb == AppCompDBs || cdb . Packages == null )
236+ if ( AppCompDBs . Contains ( cdb ) || cdb . Packages == null )
237237{
238238continue ;
239239}
@@ -543,36 +543,37 @@ await Task.WhenAll(
543543//.Where(x => UpdateUtils.ShouldFileGetDownloaded(x.x, payloadItems))
544544. OrderBy ( x=> x . Item2 . ExpirationDate ) ;
545545
546- IEnumerable < UUPFile > fileList = boundList . Select ( boundFile=>
546+ IEnumerable < UUPFile > fileList = boundList . SelectMany ( boundFile=>
547547{
548- string path = GetFilenameForCEUIFile ( boundFile . Item1 , payloadItems ) ;
549-
550- try
548+ return GetFilenameForCEUIFile ( boundFile . Item1 , payloadItems ) . Select ( path=>
551549{
552- foreach ( CompDBXmlClass . CompDB compDb in compDBs )
550+ try
553551{
554- foreach ( CompDBXmlClass . Package pkg in compDb . Packages . Package )
552+ foreach ( CompDBXmlClass . CompDB compDb in compDBs )
555553{
556- string payloadHash = pkg . Payload . PayloadItem [ 0 ] . PayloadHash ;
557- if ( payloadHash == boundFile . Item1 . AdditionalDigest . Text || payloadHash == boundFile . Item1 . Digest )
554+ foreach ( CompDBXmlClass . Package pkg in compDb . Packages . Package )
558555{
559- if ( pkg . ID . Contains ( "-" ) && pkg . ID . Contains ( ".inf" , StringComparison . InvariantCultureIgnoreCase ) )
556+ string payloadHash = pkg . Payload . PayloadItem [ 0 ] . PayloadHash ;
557+ if ( payloadHash == boundFile . Item1 . AdditionalDigest . Text || payloadHash == boundFile . Item1 . Digest )
560558{
561- path = pkg . ID . Split ( "-" ) [ 1 ] . Replace ( ".inf" , ".cab" ) . Replace ( ".INF" , ".CAB" ) ;
559+ if ( pkg . ID . Contains ( "-" ) && pkg . ID . Contains ( ".inf" , StringComparison . InvariantCultureIgnoreCase ) )
560+ {
561+ path = pkg . ID . Split ( "-" ) [ 1 ] . Replace ( ".inf" , ".cab" ) . Replace ( ".INF" , ".CAB" ) ;
562+ }
563+ break ;
562564}
563- break ;
564565}
565566}
566567}
567- }
568- catch { }
569-
570- return new UUPFile (
571- boundFile . Item2 ,
572- path ,
573- long . Parse ( boundFile . Item1 . Size ) ,
574- boundFile . Item1 . AdditionalDigest . Text ,
575- boundFile . Item1 . AdditionalDigest . Algorithm ) ;
568+ catch { }
569+
570+ return new UUPFile (
571+ boundFile . Item2 ,
572+ path ,
573+ long . Parse ( boundFile . Item1 . Size ) ,
574+ boundFile . Item1 . AdditionalDigest . Text ,
575+ boundFile . Item1 . AdditionalDigest . Algorithm ) ;
576+ } ) ;
576577} ) ;
577578
578579returnCode = await helperDl . DownloadAsync ( fileList . ToList ( ) , generalDownloadProgress ) ? 0 : - 1 ;