mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
Fallback to stock library_index.json file if the copy in .arduino15 is missing/corrupted or if it the downloaded one if corrupted. Fixes #3778
This commit is contained in:
parent
3872f5d315
commit
f511c2451f
@ -109,6 +109,11 @@ public class LibrariesIndexer {
|
||||
// Clear all installed flags
|
||||
installedLibraries.clear();
|
||||
installedLibrariesWithDuplicates.clear();
|
||||
|
||||
if (index.getLibraries() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ContributedLibrary lib : index.getLibraries()) {
|
||||
lib.setInstalled(false);
|
||||
}
|
||||
|
@ -592,11 +592,7 @@ public class BaseNoGui {
|
||||
|
||||
try {
|
||||
indexer.parseIndex();
|
||||
} catch (JsonProcessingException e) {
|
||||
FileUtils.deleteIfExists(indexFile);
|
||||
FileUtils.deleteIfExists(indexSignatureFile);
|
||||
throw e;
|
||||
} catch (SignatureVerificationFailedException e) {
|
||||
} catch (JsonProcessingException | SignatureVerificationFailedException e) {
|
||||
FileUtils.deleteIfExists(indexFile);
|
||||
FileUtils.deleteIfExists(indexSignatureFile);
|
||||
throw e;
|
||||
@ -611,6 +607,17 @@ public class BaseNoGui {
|
||||
|
||||
librariesIndexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder(), indexer);
|
||||
File librariesIndexFile = librariesIndexer.getIndexFile();
|
||||
copyStockLibraryIndexIfUpstreamIsMissing(librariesIndexFile);
|
||||
try {
|
||||
librariesIndexer.parseIndex();
|
||||
} catch (JsonProcessingException e) {
|
||||
FileUtils.deleteIfExists(librariesIndexFile);
|
||||
copyStockLibraryIndexIfUpstreamIsMissing(librariesIndexFile);
|
||||
librariesIndexer.parseIndex();
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyStockLibraryIndexIfUpstreamIsMissing(File librariesIndexFile) throws IOException {
|
||||
if (!librariesIndexFile.isFile()) {
|
||||
File defaultLibraryJsonFile = new File(getContentFile("dist"), "library_index.json");
|
||||
if (defaultLibraryJsonFile.isFile()) {
|
||||
@ -628,12 +635,6 @@ public class BaseNoGui {
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
librariesIndexer.parseIndex();
|
||||
} catch (JsonProcessingException e) {
|
||||
FileUtils.deleteIfExists(librariesIndexFile);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
static protected void initPlatform() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user