mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 17:18:49 -04:00
fix(ui): stop cancelled imports before success
Cancelled gallery jobs also set processed. Handle cancellation before completion so imports do not announce success or open a missing model. Assisted-by: Codex:gpt-6 Signed-off-by: Plamen K. Kosseff <p.kosseff@gmail.com>
This commit is contained in:
1 parent
742971c2c4
commit
0f54bdcb38
3 files changed
+8
-2
No files matched your search
@@ -241,14 +241,15 @@ export default function ImportModel() {
|
||||
pollRef.current = setInterval(async () => {
|
||||
try {
|
||||
const data = await modelsApi.getJobStatus(jobId)
|
||||
if (data.error || (data.message && data.message.startsWith('error:'))) {
|
||||
if (data.cancelled || data.error || (data.message && data.message.startsWith('error:'))) {
|
||||
transferRateRef.current.reset(jobId)
|
||||
clearInterval(pollRef.current)
|
||||
pollRef.current = null
|
||||
setIsSubmitting(false)
|
||||
setJob(null)
|
||||
let msg = 'Unknown error'
|
||||
if (typeof data.error === 'string') msg = data.error
|
||||
if (data.cancelled) msg = 'Import cancelled'
|
||||
else if (typeof data.error === 'string') msg = data.error
|
||||
else if (data.error?.message) msg = data.error.message
|
||||
else if (data.message) msg = data.message
|
||||
if (msg.startsWith('error: ')) msg = msg.substring(7)
|
||||
|
||||
@@ -297,6 +297,7 @@ export default function ModelEditor() {
|
||||
await new Promise(r => setTimeout(r, 1000))
|
||||
let data
|
||||
try { data = await modelsApi.getJobStatus(jobId) } catch { continue }
|
||||
if (data?.cancelled) throw new Error('Import cancelled')
|
||||
if (data?.error) {
|
||||
throw new Error(typeof data.error === 'string' ? data.error : 'model asset download failed')
|
||||
}
|
||||
|
||||
@@ -135,6 +135,10 @@ answers a queued import with a job id and a status URL to poll
|
||||
(`/models/jobs/{id}` — the same shape gallery installs use), and a
|
||||
download-free import with a plain success response.
|
||||
|
||||
If you cancel a queued import, the import page and model editor report the
|
||||
cancellation and stay on the current page. They report success only after the
|
||||
job succeeds.
|
||||
|
||||
## Method 2: Installing from Hugging Face
|
||||
|
||||
LocalAI can directly install models from Hugging Face:
|
||||
|
||||
Reference in new issue
Block a user