fix: unlink the entire model folder on delete
This commit is contained in:
parent
2a0d87a393
commit
5ddbf5fb34
@ -1,18 +1,11 @@
|
|||||||
import { fs, joinPath, Model } from "@janhq/core"
|
import { fs, joinPath, Model } from '@janhq/core'
|
||||||
|
|
||||||
export const deleteModelFiles = async (model: Model) => {
|
export const deleteModelFiles = async (model: Model) => {
|
||||||
try {
|
try {
|
||||||
const dirPath = await joinPath(['file://models', model.id])
|
const dirPath = await joinPath(['file://models', model.id])
|
||||||
|
// remove model folder directory
|
||||||
// remove all files under dirPath except model.json
|
await fs.unlinkSync(dirPath)
|
||||||
const files = await fs.readdirSync(dirPath)
|
} catch (err) {
|
||||||
const deletePromises = files.map(async (fileName: string) => {
|
console.error(err)
|
||||||
if (fileName !== 'model.json') {
|
}
|
||||||
return fs.unlinkSync(await joinPath([dirPath, fileName]))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
await Promise.allSettled(deletePromises)
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user