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 7
7
import cc .arduino .files .DeleteFilesOnShutdown ;
8
8
import cc .arduino .packages .DiscoveryManager ;
9
9
import cc .arduino .packages .Uploader ;
10
+ import com .fasterxml .jackson .core .JsonProcessingException ;
10
11
import org .apache .commons .logging .impl .LogFactoryImpl ;
11
12
import org .apache .commons .logging .impl .NoOpLog ;
12
13
import processing .app .debug .Compiler ;
@@ -597,9 +598,13 @@ static public void initPackages() throws Exception {
597
598
598
599
try {
599
600
indexer .parseIndex ();
601
+ } catch (JsonProcessingException e ) {
602
+ FileUtils .deleteIfExists (indexFile );
603
+ FileUtils .deleteIfExists (indexSignatureFile );
604
+ throw e ;
600
605
} catch (SignatureVerificationFailedException e ) {
601
- indexFile . delete ( );
602
- indexSignatureFile . delete ( );
606
+ FileUtils . deleteIfExists ( indexFile );
607
+ FileUtils . deleteIfExists ( indexSignatureFile );
603
608
throw e ;
604
609
}
605
610
indexer .syncWithFilesystem (getHardwareFolder ());
@@ -631,7 +636,12 @@ static public void initPackages() throws Exception {
631
636
}
632
637
}
633
638
}
634
- librariesIndexer .parseIndex ();
639
+ try {
640
+ librariesIndexer .parseIndex ();
641
+ } catch (JsonProcessingException e ) {
642
+ FileUtils .deleteIfExists (librariesIndexFile );
643
+ throw e ;
644
+ }
635
645
}
636
646
637
647
static protected void initPlatform () {
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ public static void recursiveDelete(File file) {
85
85
recursiveDelete (current );
86
86
}
87
87
}
88
- file . delete ( );
88
+ deleteIfExists ( file );
89
89
}
90
90
91
91
public static File createTempFolder () throws IOException {
@@ -269,5 +269,16 @@ public static File newFile(File parent, String... parts) {
269
269
return result ;
270
270
}
271
271
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
+ }
272
283
273
284
}
You can’t perform that action at this time.
0 commit comments