Skip to content

Commit

Permalink
Valdiate.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang committed Nov 12, 2024
1 parent fca7b71 commit 44cef85
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/install/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,23 @@ export class ComfyUIInstall {
});
}

async isValidComfyDirectory(selectedDirectory: string): Promise<{ valid: boolean; errorMessage?: string }> {
//TODO: Implement
return { valid: true };
public async isValidComfyDirectory(selectedDirectory: string): Promise<{ valid: boolean; errorMessage?: string }> {
try {
const files = await fs.promises.readdir(selectedDirectory);

if (files.includes('ComfyUI')) {
return {
valid: false,
errorMessage: 'A ComfyUI installation already exists in this directory. Please choose another location.',
};
}

return { valid: true };
} catch (error) {
return {
valid: false,
errorMessage: 'Unable to access the selected directory. Please ensure you have proper permissions.',
};
}
}
}

0 comments on commit 44cef85

Please sign in to comment.