Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing check for local file path #4

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions android/src/main/java/com/rnexecutorch/Fetcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ class Fetcher {
/*
Fetching model and tokenizer file
1. Extract file name from provided URL
2. Check if the file has a valid extension
2. If file name contains / it means that the file is local and we should return the path
3. Check if the file has a valid extension
a. For tokenizer, the extension should be .bin
b. For model, the extension should be .pte
3. Check if models directory exists, if not create it
4. Check if the file already exists in the models directory, if yes return the path
5. If the file does not exist, and is a tokenizer, fetch the file
6. If the file is a model, fetch the file with ProgressResponseBody
4. Check if models directory exists, if not create it
5. Check if the file already exists in the models directory, if yes return the path
6. If the file does not exist, and is a tokenizer, fetch the file
7. If the file is a model, fetch the file with ProgressResponseBody
*/
val fileName: String

Expand All @@ -123,6 +124,11 @@ class Fetcher {
return
}

if(fileName.contains("/")){
onComplete(fileName, null)
return
}

if (!hasValidExtension(fileName, resourceType)) {
onComplete(null, Exception("invalid_resource_extension"))
return
Expand Down
Loading