Skip to content
Merged
Changes from 3 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
5 changes: 3 additions & 2 deletions src/utils/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ export async function getModelFile(path_or_repo_id, filename, fatal = true, opti
throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")
}
}
return_path &&= env.useFSCache || env.useCustomCache;

// Initiate file retrieval
dispatchCallback(options.progress_callback, {
Expand Down Expand Up @@ -638,7 +639,7 @@ export async function getModelFile(path_or_repo_id, filename, fatal = true, opti
});

if (result) {
if (return_path) {
if (!apis.IS_NODE_ENV && return_path) {
throw new Error("Cannot return path in a browser environment.")
}
return result;
Expand All @@ -647,7 +648,7 @@ export async function getModelFile(path_or_repo_id, filename, fatal = true, opti
return response.filePath;
}

const path = await cache.match(cacheKey);
const path = await cache?.match(cacheKey);
if (path instanceof FileResponse) {
return path.filePath;
}
Expand Down