-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle multi download model, uninstall script (#932)
- Loading branch information
1 parent
a8eb3b4
commit 0954152
Showing
11 changed files
with
82 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { promises } = require('node:fs'); | ||
const os = require('os'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const yaml = require('js-yaml'); | ||
|
||
const uninstall = async () => { | ||
const cortexConfigPath = path.join(os.homedir(), '.cortexrc'); | ||
if (fs.existsSync(cortexConfigPath)) { | ||
const content = await promises.readFile(cortexConfigPath, 'utf8'); | ||
const config = yaml.load(content); | ||
if(!config) { | ||
return; | ||
} | ||
const { dataFolderPath } = config; | ||
const modelsFolderPath = path.join(dataFolderPath, 'models'); | ||
// remove all data in data folder path except models | ||
const files = fs.readdirSync(dataFolderPath); | ||
for (const file of files) { | ||
const fileStat = fs.statSync(path.join(dataFolderPath, file)); | ||
if (file !== 'models') { | ||
if (fileStat.isDirectory()) { | ||
fs.rmSync(path.join(dataFolderPath, file), { recursive: true }); | ||
} else { | ||
fs.unlinkSync(path.join(dataFolderPath, file)); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
uninstall(); |