Skip to content

Commit

Permalink
improve file exists check
Browse files Browse the repository at this point in the history
  • Loading branch information
GenericMale committed Sep 4, 2024
1 parent 91bc5c7 commit aa7e91f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ async function writeManifest(dir, manifest) {
}

async function exists(file) {
if (!file) return false
try {
await fs.access(file, fs.constants.R_OK);
return true;
Expand Down Expand Up @@ -257,7 +258,7 @@ async function downloadDigests(baseUrl, dir, manifest, config) {

async function pull(config) {
let {from, registry, dir, name} = config;
if (config.model && await exists(config.model) && (!from || !name)) {
if (await exists(config.model) && (!from || !name)) {
console.log("Parsing GGUF Metadata...");
const model = new ModelFile(config.model);
const {general} = await model.readMetadata();
Expand Down Expand Up @@ -285,7 +286,7 @@ async function pull(config) {
}

async function printMetadata(file) {
if(!file || !await exists(file.path)) {
if (!await exists(file.path)) {
throw new Error("invalid model file.");
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ollama-model-generator",
"version": "0.0.2",
"version": "0.0.3",
"description": "NodeJS script to add models to ollama without duplication.",
"homepage": "https://github.com/GenericMale/ollama-model-generator",
"bugs": "https://github.com/GenericMale/ollama-model-generator/issues",
Expand Down

0 comments on commit aa7e91f

Please sign in to comment.