mirror of
https://github.com/nimbold/Firelink.git
synced 2026-07-27 04:19:19 +00:00
fix(persistence): reset interrupted downloads to queued on startup and deduplicate LazyStore instance
- Reset items with 'downloading' or 'processing' status to 'queued'
before re-enqueue on startup to prevent phantom active state
- Include 'processing' status in recovery filter (was a zombie path)
- Remove redundant LazyStore('store.bin') from settingsStore.ts;
import shared instance from useDownloadStore.ts instead
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist, createJSONStorage, StateStorage } from 'zustand/middleware';
|
||||
import { LazyStore } from '@tauri-apps/plugin-store';
|
||||
import { info } from '@tauri-apps/plugin-log';
|
||||
|
||||
export const tauriStore = new LazyStore('store.bin');
|
||||
import { tauriStore } from './useDownloadStore';
|
||||
|
||||
const tauriStorage: StateStorage = {
|
||||
getItem: async (name: string): Promise<string | null> => {
|
||||
|
||||
@@ -533,8 +533,17 @@ export const useDownloadStore = create<DownloadState>((set, get) => ({
|
||||
downloads: downloads.length > 0 ? downloads : state.downloads
|
||||
}));
|
||||
|
||||
// Reset interrupted downloads (crashed while downloading/processing) to queued
|
||||
set((state) => ({
|
||||
downloads: state.downloads.map(d =>
|
||||
d.status === 'downloading' || d.status === 'processing'
|
||||
? { ...d, status: 'queued' as const }
|
||||
: d
|
||||
)
|
||||
}));
|
||||
|
||||
// Auto resume downloads that were active or queued
|
||||
const active = get().downloads.filter(d => d.status === 'downloading' || d.status === 'queued');
|
||||
const active = get().downloads.filter(d => d.status === 'queued');
|
||||
if (active.length > 0) {
|
||||
try {
|
||||
const settings = useSettingsStore.getState();
|
||||
|
||||
Reference in New Issue
Block a user