1
1
// Copyright (C) 2016-2022 The Neo Project.
2
- //
3
2
// The neo-cli is free software distributed under the MIT software
4
3
// license, see the accompanying file LICENSE in the main directory of
5
- // the project or http://www.opensource.org/licenses/mit-license.php
4
+ // the project or http://www.opensource.org/licenses/mit-license.php
6
5
// for more details.
7
- //
6
+ //
8
7
// Redistribution and use in source and binary forms with or without
9
8
// modifications are permitted.
10
9
@@ -174,7 +173,7 @@ private async Task InstallDependenciesAsync(Stream config, HashSet<string> insta
174
173
/// <returns></returns>
175
174
private static bool PluginExists ( string pluginName )
176
175
{
177
- return File . Exists ( $ " Plugins/ { pluginName } .dll" ) ;
176
+ return Plugin . Plugins . Any ( p => p . Name . Equals ( pluginName , StringComparison . InvariantCultureIgnoreCase ) ) ;
178
177
}
179
178
180
179
/// <summary>
@@ -190,12 +189,6 @@ private void OnUnInstallCommand(string pluginName)
190
189
return ;
191
190
}
192
191
193
- var plugin = Plugin . Plugins . FirstOrDefault ( p => p . Name == pluginName ) ;
194
- if ( plugin is not null )
195
- {
196
- Plugin . Plugins . Remove ( plugin ) ;
197
- }
198
-
199
192
foreach ( var p in Plugin . Plugins )
200
193
{
201
194
try
@@ -207,7 +200,7 @@ private void OnUnInstallCommand(string pluginName)
207
200
. GetSection ( "Dependency" )
208
201
. GetChildren ( )
209
202
. Select ( d => d . Get < string > ( ) )
210
- . Any ( v => v == pluginName ) )
203
+ . Any ( v => v . Equals ( pluginName , StringComparison . InvariantCultureIgnoreCase ) ) )
211
204
{
212
205
ConsoleHelper . Error (
213
206
$ "Can not uninstall. Other plugins depend on this plugin, try `reinstall { pluginName } ` if the plugin is broken.") ;
@@ -219,36 +212,14 @@ private void OnUnInstallCommand(string pluginName)
219
212
// ignored
220
213
}
221
214
}
222
-
223
215
try
224
216
{
225
- DeleteFiles ( new [ ] { $ "Plugins/{ pluginName } .dll", $ "Plugins/{ pluginName } /config.json" } ) ;
226
- Directory . Delete ( $ "Plugins/{ pluginName } ", false ) ;
227
- }
228
- catch ( IOException )
229
- {
217
+ Directory . Delete ( $ "Plugins/{ pluginName } ", true ) ;
230
218
}
231
-
219
+ catch ( IOException ) { }
232
220
ConsoleHelper . Info ( "Uninstall successful, please restart neo-cli." ) ;
233
221
}
234
222
235
- private static void DeleteFiles ( IEnumerable < string > list )
236
- {
237
- foreach ( var file in list )
238
- {
239
- try
240
- {
241
- if ( ! File . Exists ( file ) ) continue ;
242
- ConsoleHelper . Info ( "Deleting " , file ) ;
243
- File . Delete ( file ) ;
244
- }
245
- catch ( Exception )
246
- {
247
- // ignored
248
- }
249
- }
250
- }
251
-
252
223
/// <summary>
253
224
/// Process "plugins" command
254
225
/// </summary>
0 commit comments