fix: download model error does not reset state in model hub (#2199)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-02-29 14:35:05 +07:00 committed by GitHub
parent 44d9f5b7b9
commit 5c185d2740
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,6 +42,24 @@ export class Downloader implements Processor {
// Downloading file to a temp file first // Downloading file to a temp file first
const downloadingTempFile = `${destination}.download` const downloadingTempFile = `${destination}.download`
// adding initial download state
const initialDownloadState: DownloadState = {
modelId,
fileName,
time: {
elapsed: 0,
remaining: 0,
},
speed: 0,
percent: 0,
size: {
total: 0,
transferred: 0,
},
downloadState: 'downloading',
}
DownloadManager.instance.downloadProgressMap[modelId] = initialDownloadState
progress(rq, {}) progress(rq, {})
.on('progress', (state: any) => { .on('progress', (state: any) => {
const downloadState: DownloadState = { const downloadState: DownloadState = {