@@ -144,33 +144,22 @@ private bool Handle(IPropertyType[] propertyTypes, IDictionary<int, ILanguage> l
144144
145145 var progress = 0 ;
146146
147- Parallel . ForEachAsync ( updateBatch , async ( update , token ) =>
147+ void HandleUpdateBatch ( UpdateBatch < PropertyDataDto > update )
148148 {
149- //Foreach here, but we need to suppress the flow before each task, but not the actuall await of the task
150- Task task ;
151- using ( ExecutionContext . SuppressFlow ( ) )
152- {
153- task = Task . Run ( ( ) =>
154- {
155- using ICoreScope scope = _coreScopeProvider . CreateCoreScope ( ) ;
156- scope . Complete ( ) ;
157- using UmbracoContextReference umbracoContextReference =
158- _umbracoContextFactory . EnsureUmbracoContext ( ) ;
149+ using UmbracoContextReference umbracoContextReference = _umbracoContextFactory . EnsureUmbracoContext ( ) ;
159150
160151 progress ++ ;
161152 if ( progress % 100 == 0 )
162153 {
163- _logger . LogInformation ( " - finíshed {progress} of {total} properties" , progress ,
164- updateBatch . Count ) ;
154+ _logger . LogInformation ( " - finíshed {progress} of {total} properties" , progress , updateBatch . Count ) ;
165155 }
166156
167157 PropertyDataDto propertyDataDto = update . Poco ;
168158
169159 // NOTE: some old property data DTOs can have variance defined, even if the property type no longer varies
170160 var culture = propertyType . VariesByCulture ( )
171161 && propertyDataDto . LanguageId . HasValue
172- && languagesById . TryGetValue ( propertyDataDto . LanguageId . Value ,
173- out ILanguage ? language )
162+ && languagesById . TryGetValue ( propertyDataDto . LanguageId . Value , out ILanguage ? language )
174163 ? language . IsoCode
175164 : null ;
176165
@@ -256,11 +245,37 @@ private bool Handle(IPropertyType[] propertyTypes, IDictionary<int, ILanguage> l
256245 stringValue = UpdateDatabaseValue ( stringValue ) ;
257246
258247 propertyDataDto . TextValue = stringValue ;
259- } , token ) ;
260- }
248+ }
261249
262- await task ;
263- } ) . GetAwaiter ( ) . GetResult ( ) ;
250+ if ( DatabaseType == DatabaseType . SQLite )
251+ {
252+ // SQLite locks up if we run the migration in parallel, so... let's not.
253+ foreach ( UpdateBatch < PropertyDataDto > update in updateBatch )
254+ {
255+ HandleUpdateBatch ( update ) ;
256+ }
257+ }
258+ else
259+ {
260+ Parallel . ForEachAsync ( updateBatch , async ( update , token ) =>
261+ {
262+ //Foreach here, but we need to suppress the flow before each task, but not the actuall await of the task
263+ Task task ;
264+ using ( ExecutionContext . SuppressFlow ( ) )
265+ {
266+ task = Task . Run (
267+ ( ) =>
268+ {
269+ using ICoreScope scope = _coreScopeProvider . CreateCoreScope ( ) ;
270+ scope . Complete ( ) ;
271+ HandleUpdateBatch ( update ) ;
272+ } ,
273+ token ) ;
274+ }
275+
276+ await task ;
277+ } ) . GetAwaiter ( ) . GetResult ( ) ;
278+ }
264279
265280 updateBatch . RemoveAll ( updatesToSkip . Contains ) ;
266281
0 commit comments