mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
If previously downloaded package_index.json is older than the bundled one, the bundled one wins
This commit is contained in:
parent
2f31b8a80c
commit
4cf77cd90d
@ -1,11 +1,11 @@
|
|||||||
package processing.app;
|
package processing.app;
|
||||||
|
|
||||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||||
|
import cc.arduino.contributions.packages.ContributedTool;
|
||||||
|
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 cc.arduino.contributions.packages.ContributedTool;
|
|
||||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
|
||||||
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;
|
||||||
@ -578,21 +578,19 @@ public class BaseNoGui {
|
|||||||
static public void initPackages() throws Exception {
|
static public void initPackages() throws Exception {
|
||||||
indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder());
|
indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder());
|
||||||
File indexFile = indexer.getIndexFile();
|
File indexFile = indexer.getIndexFile();
|
||||||
if (!indexFile.isFile()) {
|
File defaultPackageJsonFile = new File(getContentFile("dist"), "package_index.json");
|
||||||
File defaultPackageJsonFile = new File(getContentFile("dist"), "package_index.json");
|
if (!indexFile.isFile() || (defaultPackageJsonFile.isFile() && defaultPackageJsonFile.lastModified() > indexFile.lastModified())) {
|
||||||
if (defaultPackageJsonFile.isFile()) {
|
FileUtils.copyFile(defaultPackageJsonFile, indexFile);
|
||||||
FileUtils.copyFile(defaultPackageJsonFile, indexFile);
|
} else if (!indexFile.isFile()) {
|
||||||
} else {
|
// Otherwise create an empty packages index
|
||||||
// Otherwise create an empty packages index
|
FileOutputStream out = null;
|
||||||
FileOutputStream out = null;
|
try {
|
||||||
try {
|
out = new FileOutputStream(indexFile);
|
||||||
out = new FileOutputStream(indexFile);
|
out.write("{ \"packages\" : [ ] }".getBytes());
|
||||||
out.write("{ \"packages\" : [ ] }".getBytes());
|
out.close();
|
||||||
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
out.close();
|
out.close();
|
||||||
} finally {
|
|
||||||
if (out != null) {
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user