@@ -84,12 +84,15 @@ await Parallel.ForEachAsync(files, options, async (localPath, cancellationToken)
8484 return ;
8585 }
8686
87- Manifest . Files . Add ( new ( )
87+ lock ( options )
8888 {
89- Path = Helpers . NormalizePath ( relativePath ) ,
90- Size = fileSize ,
91- SHA256 = fileHash
92- } ) ;
89+ Manifest . Files . Add ( new ( )
90+ {
91+ Path = Helpers . NormalizePath ( relativePath ) ,
92+ Size = fileSize ,
93+ SHA256 = fileHash
94+ } ) ;
95+ }
9396 Logger . Debug ( $ " Added - \" { relativePath } \" ") ;
9497 progress ? . ReportAdd ( 1 ) ;
9598 } ) ;
@@ -146,30 +149,35 @@ await Parallel.ForEachAsync(Manifest.Files, options, async (file, cancellationTo
146149 {
147150 if ( file . Size == 0 )
148151 {
149- UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Create , null ) ) ;
152+ lock ( options )
153+ UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Create , null ) ) ;
150154 Logger . Debug ( $ " Create - \" { localPath } \" ") ;
151155 }
152156 else
153157 {
154- UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Download , Manifest . BasePath ) ) ;
158+ lock ( options )
159+ UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Download , Manifest . BasePath ) ) ;
155160 Logger . Debug ( $ " New - \" { localPath } \" ") ;
156161 }
157162 }
158163 else if ( fileExists && file . Size == - 1 )
159164 {
160- UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Delete , null ) ) ;
165+ lock ( options )
166+ UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Delete , null ) ) ;
161167 Logger . Debug ( $ " Delete - \" { localPath } \" ") ;
162168 }
163169 else if ( fileExists && file . Size > 0 && fileSize != file . Size )
164170 {
165- UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Download , Manifest . BasePath ) ) ;
171+ lock ( options )
172+ UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Download , Manifest . BasePath ) ) ;
166173 Logger . Debug ( $ " Modified - \" { localPath } \" ") ;
167174 }
168175 else if ( fileExists && ! string . IsNullOrEmpty ( file . SHA256 ) )
169176 {
170177 if ( ! await Helpers . CheckFileHashAsync ( localPath , file . SHA256 , sha256 , c ) )
171178 {
172- UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Download , Manifest . BasePath ) ) ;
179+ lock ( options )
180+ UpdateCommands . Add ( new ( file , HMMUpdateCommandType . Download , Manifest . BasePath ) ) ;
173181 Logger . Debug ( $ " Modified - \" { localPath } \" ") ;
174182 }
175183 }
0 commit comments