File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
arduino-core/src/processing/app Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 77import cc .arduino .files .DeleteFilesOnShutdown ;
88import cc .arduino .packages .DiscoveryManager ;
99import cc .arduino .packages .Uploader ;
10+ import com .fasterxml .jackson .core .JsonProcessingException ;
1011import org .apache .commons .logging .impl .LogFactoryImpl ;
1112import org .apache .commons .logging .impl .NoOpLog ;
1213import processing .app .debug .Compiler ;
@@ -597,9 +598,13 @@ static public void initPackages() throws Exception {
597598
598599 try {
599600 indexer .parseIndex ();
601+ } catch (JsonProcessingException e ) {
602+ FileUtils .deleteIfExists (indexFile );
603+ FileUtils .deleteIfExists (indexSignatureFile );
604+ throw e ;
600605 } catch (SignatureVerificationFailedException e ) {
601- indexFile . delete ( );
602- indexSignatureFile . delete ( );
606+ FileUtils . deleteIfExists ( indexFile );
607+ FileUtils . deleteIfExists ( indexSignatureFile );
603608 throw e ;
604609 }
605610 indexer .syncWithFilesystem (getHardwareFolder ());
@@ -631,7 +636,12 @@ static public void initPackages() throws Exception {
631636 }
632637 }
633638 }
634- librariesIndexer .parseIndex ();
639+ try {
640+ librariesIndexer .parseIndex ();
641+ } catch (JsonProcessingException e ) {
642+ FileUtils .deleteIfExists (librariesIndexFile );
643+ throw e ;
644+ }
635645 }
636646
637647 static protected void initPlatform () {
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ public static void recursiveDelete(File file) {
8585 recursiveDelete (current );
8686 }
8787 }
88- file . delete ( );
88+ deleteIfExists ( file );
8989 }
9090
9191 public static File createTempFolder () throws IOException {
@@ -269,5 +269,16 @@ public static File newFile(File parent, String... parts) {
269269 return result ;
270270 }
271271
272+ public static boolean deleteIfExists (File file ) {
273+ if (file == null ) {
274+ return true ;
275+ }
276+
277+ if (!file .exists ()) {
278+ return false ;
279+ }
280+
281+ return file .delete ();
282+ }
272283
273284}
You can’t perform that action at this time.
0 commit comments