From cac24c0716a9c5306c4ae2fca0439afe5112bb90 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Sun, 18 Jan 2026 18:04:54 +0000 Subject: [PATCH] Prioritize Flask over IndexedDB --- src/lib/unified-storage.ts | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/lib/unified-storage.ts b/src/lib/unified-storage.ts index d430886..c146028 100644 --- a/src/lib/unified-storage.ts +++ b/src/lib/unified-storage.ts @@ -19,20 +19,6 @@ class UnifiedStorage { const flaskEnvUrl = import.meta.env.VITE_FLASK_BACKEND_URL const preferSQLite = localStorage.getItem('codeforge-prefer-sqlite') === 'true' - if (typeof indexedDB !== 'undefined') { - try { - console.log('[Storage] Initializing default IndexedDB backend...') - const idbAdapter = new IndexedDBAdapter() - await idbAdapter.get('_health_check') - this.adapter = idbAdapter - this.backend = 'indexeddb' - console.log('[Storage] ✓ Using IndexedDB (default)') - return - } catch (error) { - console.warn('[Storage] IndexedDB not available:', error) - } - } - if (preferFlask || flaskEnvUrl) { try { console.log('[Storage] Flask backend explicitly configured, attempting to initialize...') @@ -46,10 +32,21 @@ class UnifiedStorage { console.log('[Storage] ✓ Using Flask backend') return } catch (error) { - console.warn('[Storage] Flask backend not available, already using IndexedDB:', error) - if (this.adapter && this.backend === 'indexeddb') { - return - } + console.warn('[Storage] Flask backend not available, falling back to IndexedDB:', error) + } + } + + if (typeof indexedDB !== 'undefined') { + try { + console.log('[Storage] Initializing default IndexedDB backend...') + const idbAdapter = new IndexedDBAdapter() + await idbAdapter.get('_health_check') + this.adapter = idbAdapter + this.backend = 'indexeddb' + console.log('[Storage] ✓ Using IndexedDB (default)') + return + } catch (error) { + console.warn('[Storage] IndexedDB not available:', error) } }