7
7
8
8
import java .io .File ;
9
9
10
- import static org .hydev .mcpm .client .uninstall .UninstallResult .State .FAILED_TO_DELETE ;
11
- import static org .hydev .mcpm .client .uninstall .UninstallResult .State .SUCCESS ;
10
+ import static org .hydev .mcpm .client .uninstall .UninstallResult .State .*;
12
11
13
12
14
13
/**
@@ -28,7 +27,7 @@ public Uninstaller(PluginTracker tracker, UnloadBoundary unloader, LocalJarBound
28
27
}
29
28
30
29
@ Override
31
- public UninstallResult uninstall (UninstallInput input ) throws PluginNotFoundException {
30
+ public UninstallResult uninstall (UninstallInput input ) {
32
31
// 1. Unload plugin
33
32
// This will throw PluginNotFoundException if the plugin isn't loaded. If it is loaded,
34
33
// this will return the jar of the currently loaded plugin, which is the most precise.
@@ -46,7 +45,12 @@ public UninstallResult uninstall(UninstallInput input) throws PluginNotFoundExce
46
45
if (jar == null ) {
47
46
// This will throw PluginNotFoundException when a plugin of the name in the file system
48
47
// could not be found.
49
- jar = jarFinder .findJar (input .name ());
48
+ try {
49
+ jar = jarFinder .findJar (input .name ());
50
+ }
51
+ catch (PluginNotFoundException e ) {
52
+ return new UninstallResult (NOT_FOUND );
53
+ }
50
54
}
51
55
52
56
// 3. Delete plugin jar
@@ -56,18 +60,24 @@ public UninstallResult uninstall(UninstallInput input) throws PluginNotFoundExce
56
60
57
61
// 4. Remove manually installed flag from the tracker
58
62
tracker .removeEntry (input .name ());
63
+ var result = new UninstallResult (SUCCESS );
59
64
60
65
// 5. Remove orphan dependencies
61
66
if (input .recursive ()) {
62
67
var orphans = tracker .listOrphanPlugins (false );
63
68
for (var orphan : orphans ) {
64
- try {
65
- uninstall (new UninstallInput (orphan , true ));
69
+ var rec = uninstall (new UninstallInput (orphan , true ));
70
+
71
+ // Recursive result
72
+ result .dependencies ().put (orphan , rec .state ());
73
+ for (var pair : rec .dependencies ().entrySet ()) {
74
+ if (!result .dependencies ().containsKey (pair .getKey ())) {
75
+ result .dependencies ().put (pair .getKey (), pair .getValue ());
76
+ }
66
77
}
67
- catch (PluginNotFoundException ignored ) { }
68
78
}
69
79
}
70
80
71
- return new UninstallResult ( SUCCESS ) ;
81
+ return result ;
72
82
}
73
83
}
0 commit comments