@@ -281,11 +281,12 @@ await DownloadFileAsync(
281
281
/// <summary>
282
282
/// Updates the plugin to the latest version available from its source.
283
283
/// </summary>
284
+ /// <param name="updateAllPlugins">Action to execute when the user chooses to update all plugins.</param>
284
285
/// <param name="silentUpdate">If true, do not show any messages when there is no update available.</param>
285
286
/// <param name="usePrimaryUrlOnly">If true, only use the primary URL for updates.</param>
286
287
/// <param name="token">Cancellation token to cancel the update operation.</param>
287
288
/// <returns></returns>
288
- public static async Task CheckForPluginUpdatesAsync ( bool silentUpdate = true , bool usePrimaryUrlOnly = false , CancellationToken token = default )
289
+ public static async Task CheckForPluginUpdatesAsync ( Action < List < PluginUpdateInfo > > updateAllPlugins , bool silentUpdate = true , bool usePrimaryUrlOnly = false , CancellationToken token = default )
289
290
{
290
291
// Update the plugin manifest
291
292
await API . UpdatePluginManifestAsync ( usePrimaryUrlOnly , token ) ;
@@ -334,14 +335,20 @@ where string.Compare(existingPlugin.Metadata.Version, pluginUpdateSource.Version
334
335
API . GetTranslation ( "updateAllPluginsButtonContent" ) ,
335
336
( ) =>
336
337
{
337
- UpdateAllPlugins ( resultsForUpdate ) ;
338
+ updateAllPlugins ( resultsForUpdate ) ;
338
339
} ,
339
340
string . Join ( ", " , resultsForUpdate . Select ( x => x . PluginExistingMetadata . Name ) ) ) ;
340
341
}
341
342
342
- private static void UpdateAllPlugins ( IEnumerable < PluginUpdateInfo > resultsForUpdate )
343
+ /// <summary>
344
+ /// Updates all plugins that have available updates.
345
+ /// </summary>
346
+ /// <param name="resultsForUpdate"></param>
347
+ /// <param name="restart"></param>
348
+ public static async Task UpdateAllPluginsAsync ( IEnumerable < PluginUpdateInfo > resultsForUpdate , bool restart )
343
349
{
344
- _ = Task . WhenAll ( resultsForUpdate . Select ( async plugin =>
350
+ var anyPluginSuccess = false ;
351
+ await Task . WhenAll ( resultsForUpdate . Select ( async plugin =>
345
352
{
346
353
var downloadToFilePath = Path . Combine ( Path . GetTempPath ( ) , $ "{ plugin . Name } -{ plugin . NewVersion } .zip") ;
347
354
@@ -363,13 +370,28 @@ await DownloadFileAsync(
363
370
{
364
371
return ;
365
372
}
373
+
374
+ anyPluginSuccess = true ;
366
375
}
367
376
catch ( Exception e )
368
377
{
369
378
API . LogException ( ClassName , "Failed to update plugin" , e ) ;
370
379
API . ShowMsgError ( API . GetTranslation ( "ErrorUpdatingPlugin" ) ) ;
371
380
}
372
381
} ) ) ;
382
+
383
+ if ( ! anyPluginSuccess ) return ;
384
+
385
+ if ( restart )
386
+ {
387
+ API . RestartApp ( ) ;
388
+ }
389
+ else
390
+ {
391
+ API . ShowMsg (
392
+ API . GetTranslation ( "updatebtn" ) ,
393
+ API . GetTranslation ( "PluginsUpdateSuccessNoRestart" ) ) ;
394
+ }
373
395
}
374
396
375
397
/// <summary>
@@ -445,16 +467,16 @@ private static bool InstallSourceKnown(string url)
445
467
x . Metadata . Website . StartsWith ( constructedUrlPart )
446
468
) ;
447
469
}
470
+ }
448
471
449
- private record PluginUpdateInfo
450
- {
451
- public string ID { get ; init ; }
452
- public string Name { get ; init ; }
453
- public string Author { get ; init ; }
454
- public string CurrentVersion { get ; init ; }
455
- public string NewVersion { get ; init ; }
456
- public string IcoPath { get ; init ; }
457
- public PluginMetadata PluginExistingMetadata { get ; init ; }
458
- public UserPlugin PluginNewUserPlugin { get ; init ; }
459
- }
472
+ public record PluginUpdateInfo
473
+ {
474
+ public string ID { get ; init ; }
475
+ public string Name { get ; init ; }
476
+ public string Author { get ; init ; }
477
+ public string CurrentVersion { get ; init ; }
478
+ public string NewVersion { get ; init ; }
479
+ public string IcoPath { get ; init ; }
480
+ public PluginMetadata PluginExistingMetadata { get ; init ; }
481
+ public UserPlugin PluginNewUserPlugin { get ; init ; }
460
482
}
0 commit comments