mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Add commons-io dependency and replace the extract file name with FilenameUtils
This commit is contained in:
parent
4a944df758
commit
58fc5a5011
BIN
app/lib/commons-io-2.6.jar
Normal file
BIN
app/lib/commons-io-2.6.jar
Normal file
Binary file not shown.
BIN
arduino-core/lib/commons-io-2.6.jar
Normal file
BIN
arduino-core/lib/commons-io-2.6.jar
Normal file
Binary file not shown.
@ -33,6 +33,7 @@ import cc.arduino.utils.FileHash;
|
||||
import cc.arduino.utils.MultiStepProgress;
|
||||
import cc.arduino.utils.Progress;
|
||||
import cc.arduino.utils.network.FileDownloader;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import processing.app.BaseNoGui;
|
||||
@ -147,13 +148,13 @@ public class DownloadableContributionsDownloader {
|
||||
public void downloadIndexAndSignature(MultiStepProgress progress, URL packageIndexUrl, ProgressListener progressListener, SignatureVerifier signatureVerifier) throws Exception {
|
||||
|
||||
// Extract the file name from the url
|
||||
String[] urlPathParts = packageIndexUrl.getFile().split("/");
|
||||
File packageIndex = BaseNoGui.indexer.getIndexFile(urlPathParts[urlPathParts.length - 1]);
|
||||
String indexFileName = FilenameUtils.getName(packageIndexUrl.getPath());
|
||||
File packageIndex = BaseNoGui.indexer.getIndexFile(indexFileName);
|
||||
|
||||
final String statusText = tr("Downloading platforms index...");
|
||||
|
||||
// Create temp files
|
||||
File packageIndexTemp = File.createTempFile(packageIndexUrl.getPath(), ".tmp");
|
||||
File packageIndexTemp = File.createTempFile(indexFileName, ".tmp");
|
||||
try {
|
||||
// Download package index
|
||||
download(packageIndexUrl, packageIndexTemp, progress, statusText, progressListener, true);
|
||||
@ -195,10 +196,11 @@ public class DownloadableContributionsDownloader {
|
||||
|
||||
public boolean checkSignature(MultiStepProgress progress, URL signatureUrl, ProgressListener progressListener, SignatureVerifier signatureVerifier, String statusText, File fileToVerify) throws Exception {
|
||||
|
||||
File packageIndexSignatureTemp = File.createTempFile(signatureUrl.getPath(), ".tmp");
|
||||
// Signature file name
|
||||
String[] urlPathParts = signatureUrl.getFile().split("/");
|
||||
File packageIndexSignature = BaseNoGui.indexer.getIndexFile(urlPathParts[urlPathParts.length - 1]);
|
||||
String signatureFileName = FilenameUtils.getName(signatureUrl.getPath());
|
||||
File packageIndexSignature = BaseNoGui.indexer.getIndexFile(signatureFileName);
|
||||
File packageIndexSignatureTemp = File.createTempFile(signatureFileName, ".tmp");
|
||||
|
||||
|
||||
try {
|
||||
// Download signature
|
||||
|
@ -34,6 +34,7 @@ import cc.arduino.utils.Progress;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipUtils;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
@ -54,7 +55,8 @@ public class GZippedJsonDownloader {
|
||||
public void download(File tmpFile, Progress progress, String statusText, ProgressListener progressListener) throws Exception {
|
||||
File gzipTmpFile = null;
|
||||
try {
|
||||
gzipTmpFile = File.createTempFile(new URL(Constants.LIBRARY_INDEX_URL_GZ).getPath(), GzipUtils.getCompressedFilename(tmpFile.getName()));
|
||||
String tmpFileName = FilenameUtils.getName(new URL(Constants.LIBRARY_INDEX_URL_GZ).getPath());
|
||||
gzipTmpFile = File.createTempFile(tmpFileName, GzipUtils.getCompressedFilename(tmpFile.getName()));
|
||||
// remove eventual leftovers from previous downloads
|
||||
Files.deleteIfExists(gzipTmpFile.toPath());
|
||||
|
||||
|
@ -36,6 +36,7 @@ import cc.arduino.contributions.GZippedJsonDownloader;
|
||||
import cc.arduino.contributions.ProgressListener;
|
||||
import cc.arduino.utils.ArchiveExtractor;
|
||||
import cc.arduino.utils.MultiStepProgress;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import processing.app.BaseNoGui;
|
||||
@ -70,7 +71,8 @@ public class LibraryInstaller {
|
||||
// Step 1: Download index
|
||||
File outputFile = BaseNoGui.librariesIndexer.getIndexFile();
|
||||
// Create temp files
|
||||
File libraryIndexTemp = File.createTempFile(new URL(Constants.LIBRARY_INDEX_URL).getPath(), ".tmp");
|
||||
String signatureFileName = FilenameUtils.getName(new URL(Constants.LIBRARY_INDEX_URL).getPath());
|
||||
File libraryIndexTemp = File.createTempFile(signatureFileName, ".tmp");
|
||||
final URL libraryURL = new URL(Constants.LIBRARY_INDEX_URL);
|
||||
final String statusText = tr("Downloading libraries index...");
|
||||
try {
|
||||
|
@ -41,6 +41,7 @@ import org.apache.commons.exec.CommandLine;
|
||||
import org.apache.commons.exec.DefaultExecutor;
|
||||
import org.apache.commons.exec.Executor;
|
||||
import org.apache.commons.exec.PumpStreamHandler;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import processing.app.BaseNoGui;
|
||||
@ -298,8 +299,8 @@ public class ContributionInstaller {
|
||||
try {
|
||||
// Extract the file name from the URL
|
||||
final URL packageIndexURL = new URL(packageIndexURLString);
|
||||
String[] urlPathParts = packageIndexURL.getPath().split("/");
|
||||
downloadedPackageIndexFilesAccumulator.add(BaseNoGui.indexer.getIndexFile(urlPathParts[urlPathParts.length - 1]).getName());
|
||||
String indexFileName = FilenameUtils.getName(packageIndexURL.getPath());
|
||||
downloadedPackageIndexFilesAccumulator.add(BaseNoGui.indexer.getIndexFile(indexFileName).getName());
|
||||
|
||||
log.info("Start download and signature check of={}", packageIndexURLs);
|
||||
downloader.downloadIndexAndSignature(progress, packageIndexURL, progressListener, signatureVerifier);
|
||||
|
@ -36,6 +36,7 @@
|
||||
<cp>%EXEDIR%/lib/commons-lang3-3.8.1.jar</cp>
|
||||
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
|
||||
<cp>%EXEDIR%/lib/commons-net-3.3.jar</cp>
|
||||
<cp>%EXEDIR%/lib/commons-io-2.6.jar</cp>
|
||||
<cp>%EXEDIR%/lib/jackson-annotations-2.9.5.jar</cp>
|
||||
<cp>%EXEDIR%/lib/jackson-core-2.9.5.jar</cp>
|
||||
<cp>%EXEDIR%/lib/jackson-databind-2.9.5.jar</cp>
|
||||
|
@ -36,6 +36,7 @@
|
||||
<cp>%EXEDIR%/lib/commons-lang3-3.8.1.jar</cp>
|
||||
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
|
||||
<cp>%EXEDIR%/lib/commons-net-3.3.jar</cp>
|
||||
<cp>%EXEDIR%/lib/commons-io-2.6.jar</cp>
|
||||
<cp>%EXEDIR%/lib/jackson-annotations-2.9.5.jar</cp>
|
||||
<cp>%EXEDIR%/lib/jackson-core-2.9.5.jar</cp>
|
||||
<cp>%EXEDIR%/lib/jackson-databind-2.9.5.jar</cp>
|
||||
|
Loading…
x
Reference in New Issue
Block a user