@@ -78,77 +78,79 @@ private static BlobContainerSasPermissions ConvertPermissions(ContainerPermissio
7878 config . inputQueue = await _queue . GetQueueSas ( task . TaskId . ToString ( ) , StorageType . Corpus , QueueSasPermissions . Add | QueueSasPermissions . Read | QueueSasPermissions . Update | QueueSasPermissions . Process ) ;
7979 }
8080
81- var containersByType = definition . Containers . Where ( c => c . Type != ContainerType . Setup && task . Config . Containers != null )
82- . ToAsyncEnumerable ( )
83- . SelectAwait ( async countainerDef => {
84- var containers = await
85- task . Config . Containers !
86- . Where ( c => c . Type == countainerDef . Type ) . Select ( container => ( countainerDef , container ) )
87- . Where ( x => x . container != null )
88- . ToAsyncEnumerable ( )
89- . SelectAwait ( async ( x , i ) =>
90- new SyncedDir (
91- string . Join ( "_" , "task" , x . Item1 . Type . ToString ( ) . ToLower ( ) , i ) ,
92- await _containers . GetContainerSasUrl ( x . Item2 . Name , StorageType . Corpus , ConvertPermissions ( x . Item1 . Permissions ) ) )
93- ) . ToListAsync ( ) ;
94- return ( countainerDef , containers ) ;
95- }
96- ) ;
97-
98- await foreach ( var data in containersByType ) {
99-
100- if ( ! data . containers . Any ( ) ) {
101- continue ;
102- }
81+ if ( task . Config . Containers is not null ) {
82+ var containersByType =
83+ await Async . Task . WhenAll (
84+ definition . Containers
85+ . Where ( c => c . Type is not ContainerType . Setup )
86+ . Select ( async countainerDef => {
87+ var syncedDirs =
88+ await Async . Task . WhenAll (
89+ task . Config . Containers
90+ . Where ( c => c . Type == countainerDef . Type )
91+ . Select ( async ( container , i ) =>
92+ new SyncedDir (
93+ string . Join ( "_" , "task" , countainerDef . Type . ToString ( ) . ToLower ( ) , i ) ,
94+ await _containers . GetContainerSasUrl ( container . Name , StorageType . Corpus , ConvertPermissions ( countainerDef . Permissions ) ) )
95+ ) ) ;
96+
97+ return ( countainerDef , syncedDirs ) ;
98+ } ) ) ;
99+
100+ foreach ( var ( countainerDef , syncedDirs ) in containersByType ) {
101+ if ( ! syncedDirs . Any ( ) ) {
102+ continue ;
103+ }
103104
104- IContainerDef def = data . countainerDef switch {
105- ContainerDefinition { Compare : Compare . Equal , Value : 1 } or
106- ContainerDefinition { Compare : Compare . AtMost , Value : 1 } when data . containers . Count == 1 => new SingleContainer ( data . containers [ 0 ] ) ,
107- _ => new MultipleContainer ( data . containers )
108- } ;
109-
110- switch ( data . countainerDef . Type ) {
111- case ContainerType . Analysis :
112- config . Analysis = def ;
113- break ;
114- case ContainerType . Coverage :
115- config . Coverage = def ;
116- break ;
117- case ContainerType . Crashes :
118- config . Crashes = def ;
119- break ;
120- case ContainerType . Inputs :
121- config . Inputs = def ;
122- break ;
123- case ContainerType . NoRepro :
124- config . NoRepro = def ;
125- break ;
126- case ContainerType . ReadonlyInputs :
127- config . ReadonlyInputs = def ;
128- break ;
129- case ContainerType . Reports :
130- config . Reports = def ;
131- break ;
132- case ContainerType . Tools :
133- config . Tools = def ;
134- break ;
135- case ContainerType . UniqueInputs :
136- config . UniqueInputs = def ;
137- break ;
138- case ContainerType . UniqueReports :
139- config . UniqueReports = def ;
140- break ;
141- case ContainerType . RegressionReports :
142- config . RegressionReports = def ;
143- break ;
144- case ContainerType . Extra :
145- config . Extra = def ;
146- break ;
147- case ContainerType . ExtraRw :
148- config . ExtraRw = def ;
149- break ;
150- default :
151- throw new InvalidDataException ( $ "unknown container type: { data . countainerDef . Type } ") ;
105+ IContainerDef def = countainerDef switch {
106+ ContainerDefinition { Compare : Compare . Equal | Compare . AtMost , Value : 1 }
107+ when syncedDirs is [ var syncedDir ] => new SingleContainer ( syncedDir ) ,
108+ _ => new MultipleContainer ( syncedDirs )
109+ } ;
110+
111+ switch ( countainerDef . Type ) {
112+ case ContainerType . Analysis :
113+ config . Analysis = def ;
114+ break ;
115+ case ContainerType . Coverage :
116+ config . Coverage = def ;
117+ break ;
118+ case ContainerType . Crashes :
119+ config . Crashes = def ;
120+ break ;
121+ case ContainerType . Inputs :
122+ config . Inputs = def ;
123+ break ;
124+ case ContainerType . NoRepro :
125+ config . NoRepro = def ;
126+ break ;
127+ case ContainerType . ReadonlyInputs :
128+ config . ReadonlyInputs = def ;
129+ break ;
130+ case ContainerType . Reports :
131+ config . Reports = def ;
132+ break ;
133+ case ContainerType . Tools :
134+ config . Tools = def ;
135+ break ;
136+ case ContainerType . UniqueInputs :
137+ config . UniqueInputs = def ;
138+ break ;
139+ case ContainerType . UniqueReports :
140+ config . UniqueReports = def ;
141+ break ;
142+ case ContainerType . RegressionReports :
143+ config . RegressionReports = def ;
144+ break ;
145+ case ContainerType . Extra :
146+ config . Extra = def ;
147+ break ;
148+ case ContainerType . ExtraRw :
149+ config . ExtraRw = def ;
150+ break ;
151+ default :
152+ throw new InvalidDataException ( $ "unknown container type: { countainerDef . Type } ") ;
153+ }
152154 }
153155 }
154156
0 commit comments