@@ -79,7 +79,8 @@ protected void onProgress(Progress progress) {
79
79
};
80
80
}
81
81
82
- public void install (ContributedPlatform platform ) throws Exception {
82
+ public List <String > install (ContributedPlatform platform ) throws Exception {
83
+ List <String > errors = new LinkedList <String >();
83
84
if (platform .isInstalled ()) {
84
85
throw new Exception ("Platform is already installed!" );
85
86
}
@@ -117,7 +118,7 @@ public void install(ContributedPlatform platform) throws Exception {
117
118
}
118
119
} catch (InterruptedException e ) {
119
120
// Download interrupted... just exit
120
- return ;
121
+ return errors ;
121
122
}
122
123
123
124
ContributedPackage pack = platform .getParentPackage ();
@@ -140,7 +141,11 @@ public void install(ContributedPlatform platform) throws Exception {
140
141
destFolder .mkdirs ();
141
142
assert toolContrib .getDownloadedFile () != null ;
142
143
new ArchiveExtractor (BaseNoGui .getPlatform ()).extract (toolContrib .getDownloadedFile (), destFolder , 1 );
143
- executePostInstallScriptIfAny (destFolder );
144
+ try {
145
+ executePostInstallScriptIfAny (destFolder );
146
+ } catch (IOException e ) {
147
+ errors .add (_ ("Error running post install script" ));
148
+ }
144
149
toolContrib .setInstalled (true );
145
150
toolContrib .setInstalledFolder (destFolder );
146
151
progress .stepDone ();
@@ -159,6 +164,8 @@ public void install(ContributedPlatform platform) throws Exception {
159
164
160
165
progress .setStatus (_ ("Installation completed!" ));
161
166
onProgress (progress );
167
+
168
+ return errors ;
162
169
}
163
170
164
171
private void executePostInstallScriptIfAny (File folder ) throws IOException {
@@ -184,14 +191,15 @@ public boolean apply(File file) {
184
191
ByteArrayOutputStream stdout = new ByteArrayOutputStream ();
185
192
ByteArrayOutputStream stderr = new ByteArrayOutputStream ();
186
193
Executor executor = new CollectStdOutStdErrExecutor (stdout , stderr );
187
-
194
+ executor . setWorkingDirectory ( folder );
188
195
executor .execute (new CommandLine (postInstallScript ));
189
196
190
197
System .out .write (stdout .toByteArray ());
191
198
System .err .write (stderr .toByteArray ());
192
199
}
193
200
194
- public void remove (ContributedPlatform platform ) {
201
+ public List <String > remove (ContributedPlatform platform ) {
202
+ List <String > errors = new LinkedList <String >();
195
203
FileUtils .recursiveDelete (platform .getInstalledFolder ());
196
204
platform .setInstalled (false );
197
205
platform .setInstalledFolder (null );
@@ -217,11 +225,14 @@ public void remove(ContributedPlatform platform) {
217
225
// ignore
218
226
}
219
227
}
228
+
229
+ return errors ;
220
230
}
221
231
222
- public void updateIndex () throws Exception {
223
- final MultiStepProgress progress = new MultiStepProgress (1 );
224
- final String statusText = _ ("Downloading platforms index..." );
232
+ public List <String > updateIndex () throws Exception {
233
+ List <String > errors = new LinkedList <String >();
234
+ MultiStepProgress progress = new MultiStepProgress (1 );
235
+ String statusText = _ ("Downloading platforms index..." );
225
236
226
237
URL url = new URL (PACKAGE_INDEX_URL );
227
238
File outputFile = indexer .getIndexFile ();
@@ -232,10 +243,13 @@ public void updateIndex() throws Exception {
232
243
// TODO: Check downloaded index
233
244
234
245
// Replace old index with the updated one
235
- if (outputFile .exists ())
246
+ if (outputFile .exists ()) {
236
247
outputFile .delete ();
237
- if (!tmpFile .renameTo (outputFile ))
248
+ }
249
+ if (!tmpFile .renameTo (outputFile )) {
238
250
throw new Exception ("An error occurred while updating platforms index!" );
251
+ }
252
+ return errors ;
239
253
}
240
254
241
255
protected void onProgress (Progress progress ) {
0 commit comments