Skip to content

Commit 4a944df

Browse files
author
Mattia Bertorello
committed
Fix portable mode and make the fileCached immutable
1 parent fa77c15 commit 4a944df

File tree

4 files changed

+178
-115
lines changed

4 files changed

+178
-115
lines changed

arduino-core/src/cc/arduino/contributions/DownloadableContributionsDownloader.java

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public void downloadIndexAndSignature(MultiStepProgress progress, URL packageInd
170170
log.info("The domain is not selected to verify the signature. will be copied into this path {}, packageIndex url: {}", packageIndex, packageIndexUrl);
171171
}
172172
} catch (Exception e) {
173+
log.error("Cannot download the package index from {} the package will be discard", packageIndexUrl, e);
173174
throw e;
174175
} finally {
175176
// Delete useless temp file

arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
import java.net.URL;
4949
import java.nio.file.Files;
5050
import java.nio.file.StandardCopyOption;
51-
import java.util.LinkedList;
52-
import java.util.List;
5351
import java.util.Optional;
5452

5553
import static processing.app.I18n.tr;

arduino-core/src/cc/arduino/utils/network/FileDownloader.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private void downloadFile(boolean noResume) throws InterruptedException {
147147

148148
final Optional<FileDownloaderCache.FileCached> fileCached = FileDownloaderCache.getFileCached(downloadUrl);
149149

150-
if (fileCached.isPresent() && !fileCached.get().isChange()) {
150+
if (fileCached.isPresent() && fileCached.get().isNotChange()) {
151151
try {
152152
final Optional<File> fileFromCache =
153153
fileCached.get().getFileFromCache();
@@ -156,11 +156,17 @@ private void downloadFile(boolean noResume) throws InterruptedException {
156156
FileUtils.copyFile(fileFromCache.get(), outputFile);
157157
setStatus(Status.COMPLETE);
158158
return;
159+
} else {
160+
log.info(
161+
"The file in the cache is not in the path or the md5 validation failed: path={}, file exist={}, md5 validation={}",
162+
fileCached.get().getLocalPath(), fileCached.get().exists(), fileCached.get().md5Check());
159163
}
160164
} catch (Exception e) {
161165
log.warn(
162-
"Cannot get the file from the cache, will be downloaded a new one ", e.getCause());
166+
"Cannot get the file from the cache, will be downloaded a new one ", e);
163167
}
168+
} else {
169+
log.info("The file is change {}", fileCached);
164170
}
165171

166172
initialSize = outputFile.length();
@@ -226,10 +232,12 @@ private void downloadFile(boolean noResume) throws InterruptedException {
226232
} catch (SocketTimeoutException e) {
227233
setStatus(Status.CONNECTION_TIMEOUT_ERROR);
228234
setError(e);
235+
log.error(e);
229236

230237
} catch (Exception e) {
231238
setStatus(Status.ERROR);
232239
setError(e);
240+
log.error(e);
233241

234242
} finally {
235243
IOUtils.closeQuietly(randomAccessOutputFile);

0 commit comments

Comments
 (0)