Skip to content

Commit 613ff55

Browse files
fix: missing check for local file path (#4)
1 parent ad8df24 commit 613ff55

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

android/src/main/java/com/rnexecutorch/Fetcher.kt

+11-5
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ class Fetcher {
106106
/*
107107
Fetching model and tokenizer file
108108
1. Extract file name from provided URL
109-
2. Check if the file has a valid extension
109+
2. If file name contains / it means that the file is local and we should return the path
110+
3. Check if the file has a valid extension
110111
a. For tokenizer, the extension should be .bin
111112
b. For model, the extension should be .pte
112-
3. Check if models directory exists, if not create it
113-
4. Check if the file already exists in the models directory, if yes return the path
114-
5. If the file does not exist, and is a tokenizer, fetch the file
115-
6. If the file is a model, fetch the file with ProgressResponseBody
113+
4. Check if models directory exists, if not create it
114+
5. Check if the file already exists in the models directory, if yes return the path
115+
6. If the file does not exist, and is a tokenizer, fetch the file
116+
7. If the file is a model, fetch the file with ProgressResponseBody
116117
*/
117118
val fileName: String
118119

@@ -123,6 +124,11 @@ class Fetcher {
123124
return
124125
}
125126

127+
if(fileName.contains("/")){
128+
onComplete(fileName, null)
129+
return
130+
}
131+
126132
if (!hasValidExtension(fileName, resourceType)) {
127133
onComplete(null, Exception("invalid_resource_extension"))
128134
return

0 commit comments

Comments
 (0)