mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Deleting json files if they are some how corrupted. Fixes #3015
This commit is contained in:
@ -7,6 +7,7 @@ import cc.arduino.contributions.packages.ContributionsIndexer;
|
|||||||
import cc.arduino.files.DeleteFilesOnShutdown;
|
import cc.arduino.files.DeleteFilesOnShutdown;
|
||||||
import cc.arduino.packages.DiscoveryManager;
|
import cc.arduino.packages.DiscoveryManager;
|
||||||
import cc.arduino.packages.Uploader;
|
import cc.arduino.packages.Uploader;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import org.apache.commons.logging.impl.LogFactoryImpl;
|
import org.apache.commons.logging.impl.LogFactoryImpl;
|
||||||
import org.apache.commons.logging.impl.NoOpLog;
|
import org.apache.commons.logging.impl.NoOpLog;
|
||||||
import processing.app.debug.Compiler;
|
import processing.app.debug.Compiler;
|
||||||
@ -597,9 +598,13 @@ public class BaseNoGui {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
indexer.parseIndex();
|
indexer.parseIndex();
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
FileUtils.deleteIfExists(indexFile);
|
||||||
|
FileUtils.deleteIfExists(indexSignatureFile);
|
||||||
|
throw e;
|
||||||
} catch (SignatureVerificationFailedException e) {
|
} catch (SignatureVerificationFailedException e) {
|
||||||
indexFile.delete();
|
FileUtils.deleteIfExists(indexFile);
|
||||||
indexSignatureFile.delete();
|
FileUtils.deleteIfExists(indexSignatureFile);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
indexer.syncWithFilesystem(getHardwareFolder());
|
indexer.syncWithFilesystem(getHardwareFolder());
|
||||||
@ -631,7 +636,12 @@ public class BaseNoGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
librariesIndexer.parseIndex();
|
try {
|
||||||
|
librariesIndexer.parseIndex();
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
FileUtils.deleteIfExists(librariesIndexFile);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected void initPlatform() {
|
static protected void initPlatform() {
|
||||||
|
@ -85,7 +85,7 @@ public class FileUtils {
|
|||||||
recursiveDelete(current);
|
recursiveDelete(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.delete();
|
deleteIfExists(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File createTempFolder() throws IOException {
|
public static File createTempFolder() throws IOException {
|
||||||
@ -269,5 +269,16 @@ public class FileUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean deleteIfExists(File file) {
|
||||||
|
if (file == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user