@@ -51,7 +51,7 @@ internal PluginsManager(PluginInitContext context, Settings settings)
5151
5252 private Task _downloadManifestTask = Task . CompletedTask ;
5353
54- internal Task UpdateManifestAsync ( )
54+ internal Task UpdateManifestAsync ( bool silent = false )
5555 {
5656 if ( _downloadManifestTask . Status == TaskStatus . Running )
5757 {
@@ -60,10 +60,11 @@ internal Task UpdateManifestAsync()
6060 else
6161 {
6262 _downloadManifestTask = PluginsManifest . UpdateTask ;
63- _downloadManifestTask . ContinueWith ( _ =>
64- Context . API . ShowMsg ( Context . API . GetTranslation ( "plugin_pluginsmanager_update_failed_title" ) ,
65- Context . API . GetTranslation ( "plugin_pluginsmanager_update_failed_subtitle" ) , icoPath , false ) ,
66- TaskContinuationOptions . OnlyOnFaulted ) ;
63+ if ( ! silent )
64+ _downloadManifestTask . ContinueWith ( _ =>
65+ Context . API . ShowMsg ( Context . API . GetTranslation ( "plugin_pluginsmanager_update_failed_title" ) ,
66+ Context . API . GetTranslation ( "plugin_pluginsmanager_update_failed_subtitle" ) , icoPath , false ) ,
67+ TaskContinuationOptions . OnlyOnFaulted ) ;
6768 return _downloadManifestTask ;
6869 }
6970 }
@@ -113,8 +114,8 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
113114 . Any ( x => x . Metadata . ID == plugin . ID && x . Metadata . Version . CompareTo ( plugin . Version ) < 0 ) )
114115 {
115116 if ( MessageBox . Show ( Context . API . GetTranslation ( "plugin_pluginsmanager_update_exists" ) ,
116- Context . API . GetTranslation ( "plugin_pluginsmanager_update_title" ) ,
117- MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
117+ Context . API . GetTranslation ( "plugin_pluginsmanager_update_title" ) ,
118+ MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
118119 Context
119120 . API
120121 . ChangeQuery (
@@ -138,13 +139,13 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
138139 Environment . NewLine , Environment . NewLine ) ;
139140
140141 if ( MessageBox . Show ( message , Context . API . GetTranslation ( "plugin_pluginsmanager_install_title" ) ,
141- MessageBoxButton . YesNo ) == MessageBoxResult . No )
142+ MessageBoxButton . YesNo ) == MessageBoxResult . No )
142143 return ;
143144
144145 // at minimum should provide a name, but handle plugin that is not downloaded from plugins manifest and is a url download
145146 var downloadFilename = string . IsNullOrEmpty ( plugin . Version )
146- ? $ "{ plugin . Name } -{ Guid . NewGuid ( ) } .zip"
147- : $ "{ plugin . Name } -{ plugin . Version } .zip";
147+ ? $ "{ plugin . Name } -{ Guid . NewGuid ( ) } .zip"
148+ : $ "{ plugin . Name } -{ plugin . Version } .zip";
148149
149150 var filePath = Path . Combine ( DataLocation . PluginsDirectory , downloadFilename ) ;
150151
@@ -161,7 +162,7 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
161162 {
162163 if ( e is HttpRequestException )
163164 MessageBox . Show ( Context . API . GetTranslation ( "plugin_pluginsmanager_download_error" ) ,
164- Context . API . GetTranslation ( "plugin_pluginsmanager_downloading_plugin" ) ) ;
165+ Context . API . GetTranslation ( "plugin_pluginsmanager_downloading_plugin" ) ) ;
165166
166167 Context . API . ShowMsgError ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_error_title" ) ,
167168 string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_error_subtitle" ) ,
@@ -173,7 +174,7 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
173174 }
174175
175176 Context . API . ShowMsg ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_title" ) ,
176- Context . API . GetTranslation ( "plugin_pluginsmanager_install_success_restart" ) ) ;
177+ Context . API . GetTranslation ( "plugin_pluginsmanager_install_success_restart" ) ) ;
177178
178179 Context . API . RestartApp ( ) ;
179180 }
@@ -241,8 +242,8 @@ where existingPlugin.Metadata.Version.CompareTo(pluginFromManifest.Version) <
241242 Environment . NewLine , Environment . NewLine ) ;
242243
243244 if ( MessageBox . Show ( message ,
244- Context . API . GetTranslation ( "plugin_pluginsmanager_update_title" ) ,
245- MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
245+ Context . API . GetTranslation ( "plugin_pluginsmanager_update_title" ) ,
246+ MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
246247 {
247248 Uninstall ( x . PluginExistingMetadata , false ) ;
248249
@@ -277,11 +278,10 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
277278
278279 return false ;
279280 } ,
280- ContextData =
281+ ContextData =
281282 new UserPlugin
282283 {
283- Website = x . PluginNewUserPlugin . Website ,
284- UrlSourceCode = x . PluginNewUserPlugin . UrlSourceCode
284+ Website = x . PluginNewUserPlugin . Website , UrlSourceCode = x . PluginNewUserPlugin . UrlSourceCode
285285 }
286286 } ) ;
287287
@@ -340,21 +340,24 @@ internal List<Result> InstallFromWeb(string url)
340340 if ( Settings . WarnFromUnknownSource )
341341 {
342342 if ( ! InstallSourceKnown ( plugin . UrlDownload )
343- && MessageBox . Show ( string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_unknown_source_warning" ) ,
344- Environment . NewLine ) ,
345- Context . API . GetTranslation ( "plugin_pluginsmanager_install_unknown_source_warning_title" ) ,
346- MessageBoxButton . YesNo ) == MessageBoxResult . No )
343+ && MessageBox . Show ( string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_unknown_source_warning" ) ,
344+ Environment . NewLine ) ,
345+ Context . API . GetTranslation ( "plugin_pluginsmanager_install_unknown_source_warning_title" ) ,
346+ MessageBoxButton . YesNo ) == MessageBoxResult . No )
347347 return false ;
348348 }
349349
350350 Application . Current . MainWindow . Hide ( ) ;
351351 _ = InstallOrUpdate ( plugin ) ;
352-
352+
353353 return ShouldHideWindow ;
354354 }
355355 } ;
356356
357- return new List < Result > { result } ;
357+ return new List < Result >
358+ {
359+ result
360+ } ;
358361 }
359362
360363 private bool InstallSourceKnown ( string url )
@@ -377,7 +380,7 @@ internal async ValueTask<List<Result>> RequestInstallOrUpdate(string searchName,
377380
378381 var searchNameWithoutKeyword = searchName . Replace ( Settings . HotKeyInstall , string . Empty , StringComparison . OrdinalIgnoreCase ) . Trim ( ) ;
379382
380- if ( Uri . IsWellFormedUriString ( searchNameWithoutKeyword , UriKind . Absolute )
383+ if ( Uri . IsWellFormedUriString ( searchNameWithoutKeyword , UriKind . Absolute )
381384 && searchNameWithoutKeyword . Split ( '.' ) . Last ( ) == zip )
382385 return InstallFromWeb ( searchNameWithoutKeyword ) ;
383386
@@ -438,21 +441,21 @@ private void Install(UserPlugin plugin, string downloadedFilePath)
438441 if ( string . IsNullOrEmpty ( metadataJsonFilePath ) || string . IsNullOrEmpty ( pluginFolderPath ) )
439442 {
440443 MessageBox . Show ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_errormetadatafile" ) ,
441- Context . API . GetTranslation ( "plugin_pluginsmanager_install_error_title" ) ) ;
442-
443- throw new FileNotFoundException (
444+ Context . API . GetTranslation ( "plugin_pluginsmanager_install_error_title" ) ) ;
445+
446+ throw new FileNotFoundException (
444447 string . Format ( "Unable to find plugin.json from the extracted zip file, or this path {0} does not exist" , pluginFolderPath ) ) ;
445448 }
446449
447450 if ( SameOrLesserPluginVersionExists ( metadataJsonFilePath ) )
448451 {
449452 MessageBox . Show ( string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_error_duplicate" ) , plugin . Name ) ,
450- Context . API . GetTranslation ( "plugin_pluginsmanager_install_error_title" ) ) ;
453+ Context . API . GetTranslation ( "plugin_pluginsmanager_install_error_title" ) ) ;
451454
452455 throw new InvalidOperationException (
453456 string . Format ( "A plugin with the same ID and version already exists, " +
454- "or the version is greater than this downloaded plugin {0}" ,
455- plugin . Name ) ) ;
457+ "or the version is greater than this downloaded plugin {0}" ,
458+ plugin . Name ) ) ;
456459 }
457460
458461 var directory = string . IsNullOrEmpty ( plugin . Version ) ? $ "{ plugin . Name } -{ Guid . NewGuid ( ) } " : $ "{ plugin . Name } -{ plugin . Version } ";
@@ -491,8 +494,8 @@ internal List<Result> RequestUninstall(string search)
491494 Environment . NewLine , Environment . NewLine ) ;
492495
493496 if ( MessageBox . Show ( message ,
494- Context . API . GetTranslation ( "plugin_pluginsmanager_uninstall_title" ) ,
495- MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
497+ Context . API . GetTranslation ( "plugin_pluginsmanager_uninstall_title" ) ,
498+ MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
496499 {
497500 Application . Current . MainWindow . Hide ( ) ;
498501 Uninstall ( x . Metadata ) ;
@@ -554,8 +557,8 @@ private bool SameOrLesserPluginVersionExists(string metadataPath)
554557 {
555558 var newMetadata = JsonSerializer . Deserialize < PluginMetadata > ( File . ReadAllText ( metadataPath ) ) ;
556559 return Context . API . GetAllPlugins ( )
557- . Any ( x => x . Metadata . ID == newMetadata . ID
558- && newMetadata . Version . CompareTo ( x . Metadata . Version ) <= 0 ) ;
560+ . Any ( x => x . Metadata . ID == newMetadata . ID
561+ && newMetadata . Version . CompareTo ( x . Metadata . Version ) <= 0 ) ;
559562 }
560563 }
561- }
564+ }
0 commit comments