From 3bcece6c73187ab29d1a98408c50efdf8b31d915 Mon Sep 17 00:00:00 2001 From: Frank Liu Date: Fri, 19 Jan 2024 17:10:06 -0800 Subject: [PATCH] [api] Allows to load .pt or .onnx file from jar url (#2955) --- .../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); }