|
11 | 11 | import java.nio.file.Files; |
12 | 12 | import java.nio.file.Path; |
13 | 13 | import java.util.ArrayList; |
| 14 | +import java.util.LinkedHashSet; |
14 | 15 | import java.util.List; |
| 16 | +import java.util.Objects; |
15 | 17 | import java.util.Optional; |
16 | 18 | import java.util.concurrent.TimeUnit; |
17 | 19 | import java.util.concurrent.atomic.AtomicReference; |
@@ -271,7 +273,8 @@ public void copyToFastJar(List<ModelDownloadedBuildItem> models, |
271 | 273 | Path quarkusAppDir = jarPath.getParent(); |
272 | 274 | Path jlamaInQuarkusAppDir = quarkusAppDir.resolve("jlama"); |
273 | 275 |
|
274 | | - for (ModelDownloadedBuildItem bi : models) { |
| 276 | + // Using LinkedHashSet to guarantee uniqueness of models |
| 277 | + for (ModelDownloadedBuildItem bi : new LinkedHashSet<>(models)) { |
275 | 278 | try { |
276 | 279 | JlamaModelRegistry.ModelInfo modelInfo = JlamaModelRegistry.ModelInfo.from(bi.getModelName()); |
277 | 280 | Path targetDir = jlamaInQuarkusAppDir.resolve(modelInfo.toFileName()); |
@@ -301,5 +304,19 @@ public String getModelName() { |
301 | 304 | public Path getDirectory() { |
302 | 305 | return directory; |
303 | 306 | } |
| 307 | + |
| 308 | + @Override |
| 309 | + public boolean equals(Object o) { |
| 310 | + if (!(o instanceof ModelDownloadedBuildItem that)) { |
| 311 | + return false; |
| 312 | + } |
| 313 | + |
| 314 | + return Objects.equals(modelName, that.modelName) && Objects.equals(directory, that.directory); |
| 315 | + } |
| 316 | + |
| 317 | + @Override |
| 318 | + public int hashCode() { |
| 319 | + return Objects.hash(modelName, directory); |
| 320 | + } |
304 | 321 | } |
305 | 322 | } |
0 commit comments