@@ -281,11 +281,12 @@ await DownloadFileAsync(
281281 /// <summary>
282282 /// Updates the plugin to the latest version available from its source.
283283 /// </summary>
284+ /// <param name="updateAllPlugins">Action to execute when the user chooses to update all plugins.</param>
284285 /// <param name="silentUpdate">If true, do not show any messages when there is no update available.</param>
285286 /// <param name="usePrimaryUrlOnly">If true, only use the primary URL for updates.</param>
286287 /// <param name="token">Cancellation token to cancel the update operation.</param>
287288 /// <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 )
289290 {
290291 // Update the plugin manifest
291292 await API . UpdatePluginManifestAsync ( usePrimaryUrlOnly , token ) ;
@@ -334,14 +335,20 @@ where string.Compare(existingPlugin.Metadata.Version, pluginUpdateSource.Version
334335 API . GetTranslation ( "updateAllPluginsButtonContent" ) ,
335336 ( ) =>
336337 {
337- UpdateAllPlugins ( resultsForUpdate ) ;
338+ updateAllPlugins ( resultsForUpdate ) ;
338339 } ,
339340 string . Join ( ", " , resultsForUpdate . Select ( x => x . PluginExistingMetadata . Name ) ) ) ;
340341 }
341342
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 )
343349 {
344- _ = Task . WhenAll ( resultsForUpdate . Select ( async plugin =>
350+ var anyPluginSuccess = false ;
351+ await Task . WhenAll ( resultsForUpdate . Select ( async plugin =>
345352 {
346353 var downloadToFilePath = Path . Combine ( Path . GetTempPath ( ) , $ "{ plugin . Name } -{ plugin . NewVersion } .zip") ;
347354
@@ -363,13 +370,28 @@ await DownloadFileAsync(
363370 {
364371 return ;
365372 }
373+
374+ anyPluginSuccess = true ;
366375 }
367376 catch ( Exception e )
368377 {
369378 API . LogException ( ClassName , "Failed to update plugin" , e ) ;
370379 API . ShowMsgError ( API . GetTranslation ( "ErrorUpdatingPlugin" ) ) ;
371380 }
372381 } ) ) ;
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+ }
373395 }
374396
375397 /// <summary>
@@ -445,16 +467,16 @@ private static bool InstallSourceKnown(string url)
445467 x . Metadata . Website . StartsWith ( constructedUrlPart )
446468 ) ;
447469 }
470+ }
448471
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 ; }
460482}
0 commit comments