mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-11 03:59:09 +00:00
fix: resolve low severity vulnerabilities from deepseek audit
This commit is contained in:
@@ -422,7 +422,9 @@ export const AddDownloadsModal = () => {
|
||||
fileExistsOnDisk = await invoke('check_file_exists', {
|
||||
path: await resolveDownloadFilePath(itemLocation, finalFile)
|
||||
});
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.error("Failed to check if file exists on disk:", e);
|
||||
}
|
||||
|
||||
if (fileExistsInStore || fileExistsOnDisk) {
|
||||
newConflicts.push({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useDownloadStore, DownloadItem } from '../store/useDownloadStore';
|
||||
import { useDownloadProgressStore } from '../store/downloadStore';
|
||||
import { useShallow } from 'zustand/react/shallow';
|
||||
import { useSettingsStore } from '../store/useSettingsStore';
|
||||
import { ChevronDown, ChevronRight, FolderPlus, Info, CheckCircle, AlertCircle, Play, Pause } from 'lucide-react';
|
||||
import { open } from '@tauri-apps/plugin-dialog';
|
||||
@@ -15,16 +16,16 @@ type LoginMode = 'matching' | 'custom' | 'none';
|
||||
export const PropertiesModal = () => {
|
||||
const selectedPropertiesDownloadId = useDownloadStore(state => state.selectedPropertiesDownloadId);
|
||||
const setSelectedPropertiesDownloadId = useDownloadStore(state => state.setSelectedPropertiesDownloadId);
|
||||
const item = useDownloadStore(state =>
|
||||
const item = useDownloadStore(useShallow(state =>
|
||||
selectedPropertiesDownloadId
|
||||
? state.downloads.find(d => d.id === selectedPropertiesDownloadId) ?? null
|
||||
: null
|
||||
);
|
||||
const liveProgress = useDownloadProgressStore(state =>
|
||||
));
|
||||
const liveProgress = useDownloadProgressStore(useShallow(state =>
|
||||
selectedPropertiesDownloadId
|
||||
? state.progressMap[selectedPropertiesDownloadId]
|
||||
: undefined
|
||||
);
|
||||
));
|
||||
|
||||
const { baseDownloadFolder, perServerConnections } = useSettingsStore();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { UnlistenFn } from '@tauri-apps/api/event';
|
||||
import type { DownloadProgressEvent } from '../bindings/DownloadProgressEvent';
|
||||
import type { DownloadStatus } from '../bindings/DownloadStatus';
|
||||
import { listenEvent as listen } from '../ipc';
|
||||
import type { DownloadItem } from '../bindings/DownloadItem';
|
||||
|
||||
interface DownloadProgressState {
|
||||
progressMap: Record<string, DownloadProgressEvent>;
|
||||
@@ -58,7 +59,7 @@ export async function initDownloadListener() {
|
||||
if (current) {
|
||||
const status = payload.status as DownloadStatus;
|
||||
const progress = useDownloadProgressStore.getState().progressMap[payload.id];
|
||||
const updates: Partial<any> = {
|
||||
const updates: Partial<DownloadItem> = {
|
||||
status,
|
||||
...(progress ? { fraction: progress.fraction } : {})
|
||||
};
|
||||
|
||||
@@ -35,7 +35,9 @@ export async function dispatchItem(id: string): Promise<boolean> {
|
||||
if (login) {
|
||||
try {
|
||||
keychainPassword = await invoke('get_keychain_password', { id: login.id });
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.warn("Failed to retrieve keychain password for dispatch:", e);
|
||||
}
|
||||
}
|
||||
|
||||
const enqueueItem = {
|
||||
@@ -813,18 +815,51 @@ export const useDownloadStore = create<DownloadState>((set, get) => ({
|
||||
}));
|
||||
|
||||
let lastSavedDownloads = '';
|
||||
let downloadsSave = Promise.resolve();
|
||||
let queuesSave = Promise.resolve();
|
||||
let isSavingDownloads = false;
|
||||
let nextDownloadsData: string | null = null;
|
||||
|
||||
useDownloadStore.subscribe(async (state, prevState) => {
|
||||
async function processDownloadsSave() {
|
||||
if (isSavingDownloads || !nextDownloadsData) return;
|
||||
isSavingDownloads = true;
|
||||
while (nextDownloadsData) {
|
||||
const data = nextDownloadsData;
|
||||
nextDownloadsData = null;
|
||||
try {
|
||||
await invoke('db_replace_downloads', { data });
|
||||
} catch (error) {
|
||||
console.error('Failed to persist downloads:', error);
|
||||
}
|
||||
}
|
||||
isSavingDownloads = false;
|
||||
}
|
||||
|
||||
let lastSavedQueues = '';
|
||||
let isSavingQueues = false;
|
||||
let nextQueuesData: string | null = null;
|
||||
|
||||
async function processQueuesSave() {
|
||||
if (isSavingQueues || !nextQueuesData) return;
|
||||
isSavingQueues = true;
|
||||
while (nextQueuesData) {
|
||||
const data = nextQueuesData;
|
||||
nextQueuesData = null;
|
||||
try {
|
||||
await invoke('db_replace_queues', { data });
|
||||
} catch (error) {
|
||||
console.error('Failed to persist queues:', error);
|
||||
}
|
||||
}
|
||||
isSavingQueues = false;
|
||||
}
|
||||
|
||||
useDownloadStore.subscribe((state, prevState) => {
|
||||
if (state.queues !== prevState.queues) {
|
||||
const data = JSON.stringify(state.queues);
|
||||
queuesSave = queuesSave
|
||||
.then(() => invoke('db_replace_queues', { data }))
|
||||
.catch(error => {
|
||||
console.error('Failed to persist queues:', error);
|
||||
});
|
||||
await queuesSave;
|
||||
if (data !== lastSavedQueues) {
|
||||
lastSavedQueues = data;
|
||||
nextQueuesData = data;
|
||||
processQueuesSave();
|
||||
}
|
||||
}
|
||||
|
||||
if (state.downloads !== prevState.downloads) {
|
||||
@@ -836,12 +871,8 @@ useDownloadStore.subscribe(async (state, prevState) => {
|
||||
const currentSerialized = JSON.stringify(staticDownloads);
|
||||
if (currentSerialized !== lastSavedDownloads) {
|
||||
lastSavedDownloads = currentSerialized;
|
||||
downloadsSave = downloadsSave
|
||||
.then(() => invoke('db_replace_downloads', { data: currentSerialized }))
|
||||
.catch(error => {
|
||||
console.error('Failed to persist downloads:', error);
|
||||
});
|
||||
await downloadsSave;
|
||||
nextDownloadsData = currentSerialized;
|
||||
processDownloadsSave();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user