Skip to content

Commit 420ed8b

Browse files
committed
keep improving progress tracking
1 parent d0696a5 commit 420ed8b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/java/io/bioimage/modelrunner/bioimageio/download/DownloadTracker.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import java.util.Set;
3434
import java.util.stream.Collectors;
3535

36+
import io.bioimage.modelrunner.engine.installation.EngineInstall;
37+
3638
/**
3739
* Class that contains the methods to track the progress downloading files.
3840
* The files have to be downloaded to the same folder.
@@ -135,9 +137,13 @@ private DownloadTracker(String folder, TwoParameterConsumer<String, Double> cons
135137
this.folder = folder;
136138
sizeFiles = new LinkedHashMap<String, Long>();
137139
for (String link : links) {
140+
String key = folder + File.separator + DownloadModel.getFileNameFromURLString(link);
141+
if (consumer.get().get(key + EngineInstall.NBYTES_SUFFIX) != null && consumer.get().get(key + EngineInstall.NBYTES_SUFFIX) != -1) {
142+
sizeFiles.put(key, consumer.get().get(key + EngineInstall.NBYTES_SUFFIX).longValue());
143+
continue;
144+
}
138145
try {
139-
sizeFiles.put(folder + File.separator + DownloadModel.getFileNameFromURLString(link),
140-
DownloadModel.getFileSize(new URL(link)));
146+
sizeFiles.put(key, DownloadModel.getFileSize(new URL(link)));
141147
} catch (MalformedURLException e) {
142148
throw new IOException("The URL '" + link + "' cannot be found.");
143149
}

src/main/java/io/bioimage/modelrunner/engine/installation/EngineInstall.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ public long getBasicDownloadTotalSize() {
577577
long engineSize = 0;
578578
DeepLearningVersion dlVersion = DeepLearningVersion.fromFile(new File(ee.getValue()));
579579
for (String link : dlVersion.getJars()) {
580-
String key = DownloadModel.getFileNameFromURLString(link) + NBYTES_SUFFIX;
580+
String key = ee.getValue() + File.separator + DownloadModel.getFileNameFromURLString(link) + NBYTES_SUFFIX;
581581
long val = DownloadModel.getFileSize(new URL(link));
582582
this.consumersMap.get(ee.getValue()).accept(key, (double) val);
583583
engineSize += val;
@@ -631,7 +631,7 @@ public static boolean installEngineByCompleteName(String engineDir,
631631
if (dlVersion == null)
632632
throw new IOException("JDLL does not support any engine compatible with the provided engine directory: "
633633
+ engineDir);
634-
return installEngine(dlVersion, consumer);
634+
return installEngineInDir(dlVersion, engineFileDir.getParentFile().getAbsolutePath(), consumer);
635635
}
636636

637637
/**

0 commit comments

Comments
 (0)