Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix: retry/resume downloads recover meta from bundle definitions

PurpleDoubleDa653ab9c5b78
diff --git a/src/api/discover.ts b/src/api/discover.ts
index 8d0a7dbb..a9d68983 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -489,6 +489,25 @@ export async function startModelDownloadToPath(url: string, destDir: string, fil
return backendCall('download_model_to_path', { url, destDir, filename, expectedBytes: expectedBytes ?? null })
}
+/** Look up download URL + subfolder for a file by filename — searches all bundles + text models */
+export function lookupFileMeta(filename: string): { url: string; subfolder: string } | null {
+ // Search image + video bundles
+ for (const bundle of [...getImageBundles(), ...getVideoBundles()]) {
+ for (const f of bundle.files) {
+ if (f.filename === filename && f.downloadUrl && f.subfolder) {
+ return { url: f.downloadUrl, subfolder: f.subfolder }
+ }
+ }
+ }
+ // Search text models
+ for (const m of [...getUncensoredTextModels(), ...getMainstreamTextModels()]) {
+ if (m.filename === filename && m.downloadUrl && m.subfolder) {
+ return { url: m.downloadUrl, subfolder: m.subfolder }
+ }
+ }
+ return null
+}
+
// ─── Image Model Bundles ───
export function getImageBundles(): ModelBundle[] {
diff --git a/src/stores/downloadStore.ts b/src/stores/downloadStore.ts
index cedc05bb..8e46951e 100644
--- a/src/stores/downloadStore.ts
+++ b/src/stores/downloadStore.ts
@@ -1,5 +1,5 @@
import { create } from 'zustand'
-import { getDownloadProgress, pauseDownload, cancelDownload, resumeDownload, startModelDownload, startModelDownloadToPath, type DownloadProgress } from '../api/discover'
+import { getDownloadProgress, pauseDownload, cancelDownload, resumeDownload, startModelDownload, startModelDownloadToPath, lookupFileMeta, type DownloadProgress } from '../api/discover'
// Maps filename → bundle name for grouped display
type BundleMap = Record<string, string>
@@ -119,15 +119,31 @@ export const useDownloadStore = create<DownloadStoreState>()((set, get) => ({
},
resume: async (id: string) => {
- const meta = get().downloadMeta[id]
- if (!meta) return
+ let meta = get().downloadMeta[id]
+ if (!meta) {
+ const found = lookupFileMeta(id)
+ if (found) {
+ meta = { url: found.url, subfolder: found.subfolder }
+ get().setMeta(id, found.url, found.subfolder)
+ } else return
+ }
await resumeDownload(id, meta.url, meta.subfolder)
get().startPolling()
},
retry: async (id: string) => {
- const meta = get().downloadMeta[id]
- if (!meta) return
+ let meta = get().downloadMeta[id]
+ // If meta is missing (e.g. after error/restart), try to recover from bundle definitions
+ if (!meta) {
+ const found = lookupFileMeta(id)
+ if (found) {
+ meta = { url: found.url, subfolder: found.subfolder }
+ get().setMeta(id, found.url, found.subfolder)
+ } else {
+ console.warn('[downloadStore] retry: no meta found for', id)
+ return
+ }
+ }
// Clear the error state first
set(s => {
const updated = { ...s.downloads }