@@ -79,7 +79,8 @@ protected void onProgress(Progress progress) {
7979 };
8080 }
8181
82- public void install (ContributedPlatform platform ) throws Exception {
82+ public List <String > install (ContributedPlatform platform ) throws Exception {
83+ List <String > errors = new LinkedList <String >();
8384 if (platform .isInstalled ()) {
8485 throw new Exception ("Platform is already installed!" );
8586 }
@@ -117,7 +118,7 @@ public void install(ContributedPlatform platform) throws Exception {
117118 }
118119 } catch (InterruptedException e ) {
119120 // Download interrupted... just exit
120- return ;
121+ return errors ;
121122 }
122123
123124 ContributedPackage pack = platform .getParentPackage ();
@@ -140,7 +141,11 @@ public void install(ContributedPlatform platform) throws Exception {
140141 destFolder .mkdirs ();
141142 assert toolContrib .getDownloadedFile () != null ;
142143 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+ }
144149 toolContrib .setInstalled (true );
145150 toolContrib .setInstalledFolder (destFolder );
146151 progress .stepDone ();
@@ -159,6 +164,8 @@ public void install(ContributedPlatform platform) throws Exception {
159164
160165 progress .setStatus (_ ("Installation completed!" ));
161166 onProgress (progress );
167+
168+ return errors ;
162169 }
163170
164171 private void executePostInstallScriptIfAny (File folder ) throws IOException {
@@ -184,14 +191,15 @@ public boolean apply(File file) {
184191 ByteArrayOutputStream stdout = new ByteArrayOutputStream ();
185192 ByteArrayOutputStream stderr = new ByteArrayOutputStream ();
186193 Executor executor = new CollectStdOutStdErrExecutor (stdout , stderr );
187-
194+ executor . setWorkingDirectory ( folder );
188195 executor .execute (new CommandLine (postInstallScript ));
189196
190197 System .out .write (stdout .toByteArray ());
191198 System .err .write (stderr .toByteArray ());
192199 }
193200
194- public void remove (ContributedPlatform platform ) {
201+ public List <String > remove (ContributedPlatform platform ) {
202+ List <String > errors = new LinkedList <String >();
195203 FileUtils .recursiveDelete (platform .getInstalledFolder ());
196204 platform .setInstalled (false );
197205 platform .setInstalledFolder (null );
@@ -217,11 +225,14 @@ public void remove(ContributedPlatform platform) {
217225 // ignore
218226 }
219227 }
228+
229+ return errors ;
220230 }
221231
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..." );
225236
226237 URL url = new URL (PACKAGE_INDEX_URL );
227238 File outputFile = indexer .getIndexFile ();
@@ -232,10 +243,13 @@ public void updateIndex() throws Exception {
232243 // TODO: Check downloaded index
233244
234245 // Replace old index with the updated one
235- if (outputFile .exists ())
246+ if (outputFile .exists ()) {
236247 outputFile .delete ();
237- if (!tmpFile .renameTo (outputFile ))
248+ }
249+ if (!tmpFile .renameTo (outputFile )) {
238250 throw new Exception ("An error occurred while updating platforms index!" );
251+ }
252+ return errors ;
239253 }
240254
241255 protected void onProgress (Progress progress ) {
0 commit comments