fix: model downloads broken on nightly (#1984)
* fix: download error state handling * fix: download error on Windows
This commit is contained in:
parent
5ec4b8e532
commit
212397d193
@ -1,5 +1,5 @@
|
||||
import { DownloadRoute } from '../../../api'
|
||||
import { join } from 'path'
|
||||
import { join, sep } from 'path'
|
||||
import { DownloadManager } from '../../download'
|
||||
import { HttpServer } from '../HttpServer'
|
||||
import { createWriteStream } from 'fs'
|
||||
@ -38,7 +38,7 @@ export const downloadRouter = async (app: HttpServer) => {
|
||||
})
|
||||
|
||||
const localPath = normalizedArgs[1]
|
||||
const array = localPath.split('/')
|
||||
const array = localPath.split(sep)
|
||||
const fileName = array.pop() ?? ''
|
||||
const modelId = array.pop() ?? ''
|
||||
console.debug('downloadFile', normalizedArgs, fileName, modelId)
|
||||
@ -99,7 +99,7 @@ export const downloadRouter = async (app: HttpServer) => {
|
||||
})
|
||||
|
||||
const localPath = normalizedArgs[0]
|
||||
const fileName = localPath.split('/').pop() ?? ''
|
||||
const fileName = localPath.split(sep).pop() ?? ''
|
||||
const rq = DownloadManager.instance.networkRequests[fileName]
|
||||
DownloadManager.instance.networkRequests[fileName] = undefined
|
||||
rq?.abort()
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ipcMain } from 'electron'
|
||||
import { resolve } from 'path'
|
||||
import { resolve, sep } from 'path'
|
||||
import { WindowManager } from './../managers/window'
|
||||
import request from 'request'
|
||||
import { createWriteStream, renameSync } from 'fs'
|
||||
@ -46,7 +46,7 @@ export function handleDownloaderIPCs() {
|
||||
DownloadEvent.onFileDownloadError,
|
||||
{
|
||||
fileName,
|
||||
err: { message: 'aborted' },
|
||||
error: 'aborted',
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -68,7 +68,7 @@ export function handleDownloaderIPCs() {
|
||||
if (typeof localPath === 'string') {
|
||||
localPath = normalizeFilePath(localPath)
|
||||
}
|
||||
const array = localPath.split('/')
|
||||
const array = localPath.split(sep)
|
||||
const fileName = array.pop() ?? ''
|
||||
const modelId = array.pop() ?? ''
|
||||
|
||||
@ -92,13 +92,13 @@ export function handleDownloaderIPCs() {
|
||||
}
|
||||
)
|
||||
})
|
||||
.on('error', function (err: Error) {
|
||||
.on('error', function (error: Error) {
|
||||
WindowManager?.instance.currentWindow?.webContents.send(
|
||||
DownloadEvent.onFileDownloadError,
|
||||
{
|
||||
fileName,
|
||||
err,
|
||||
modelId,
|
||||
error,
|
||||
}
|
||||
)
|
||||
})
|
||||
@ -121,7 +121,7 @@ export function handleDownloaderIPCs() {
|
||||
{
|
||||
fileName,
|
||||
modelId,
|
||||
err: { message: 'aborted' },
|
||||
error: 'aborted',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@ -44,7 +44,10 @@ export const setDownloadStateAtom = atom(
|
||||
})
|
||||
} else {
|
||||
let error = state.error
|
||||
if (state.error?.includes('certificate')) {
|
||||
if (
|
||||
typeof error?.includes === 'function' &&
|
||||
state.error?.includes('certificate')
|
||||
) {
|
||||
error +=
|
||||
'. To fix enable "Ignore SSL Certificates" in Advanced settings.'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user