Skip to content

Commit

Permalink
fix: missing check for local file path (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
NorbertKlockiewicz authored Nov 8, 2024
1 parent ad8df24 commit 613ff55
Showing 1 changed file with 11 additions and 5 deletions.
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

0 comments on commit 613ff55

Please sign in to comment.