From 4ec30074b2c564ce5e9eafb43626d8985ea4f8d2 Mon Sep 17 00:00:00 2001 From: Frank Liu Date: Fri, 19 Jan 2024 08:44:19 -0800 Subject: [PATCH] [api] Allows to load .pt or .onnx file from jar url --- .../main/java/ai/djl/repository/RepositoryFactoryImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ai/djl/repository/RepositoryFactoryImpl.java b/api/src/main/java/ai/djl/repository/RepositoryFactoryImpl.java index 71f394d6d14..a730a57cb54 100644 --- a/api/src/main/java/ai/djl/repository/RepositoryFactoryImpl.java +++ b/api/src/main/java/ai/djl/repository/RepositoryFactoryImpl.java @@ -160,11 +160,10 @@ public Repository newInstance(String name, URI uri) { Path path = Paths.get(parseFilePath(uri)); String fileName = path.toFile().getName(); - if (!FilenameUtils.isArchiveFile(fileName)) { - throw new IllegalArgumentException("Only archive file is supported for res URL."); + if (FilenameUtils.isArchiveFile(fileName)) { + fileName = FilenameUtils.getNamePart(fileName); } - fileName = FilenameUtils.getNamePart(fileName); return new JarRepository(name, uri, fileName, queryString); }