mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-08 10:23:29 +00:00
feat: implement native OS file management and trash utilities
This commit is contained in:
@@ -255,7 +255,7 @@ export const DownloadTable: React.FC<DownloadTableProps> = ({ filter }) => {
|
||||
setContextMenu(null);
|
||||
try {
|
||||
const fullPath = await resolvePath(contextItem.destination || '~/Downloads', contextItem.fileName);
|
||||
await invoke('open_file', { path: fullPath });
|
||||
await invoke('open_downloaded_file', { path: fullPath });
|
||||
} catch (e) {
|
||||
console.error("Failed to open file:", e);
|
||||
}
|
||||
@@ -271,7 +271,7 @@ export const DownloadTable: React.FC<DownloadTableProps> = ({ filter }) => {
|
||||
setContextMenu(null);
|
||||
try {
|
||||
const fullPath = await resolvePath(contextItem.destination || '~/Downloads', contextItem.fileName);
|
||||
await invoke('show_in_folder', { path: fullPath });
|
||||
await invoke('reveal_in_file_manager', { path: fullPath });
|
||||
} catch (e) {
|
||||
console.error("Failed to show in folder:", e);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@ type CommandMap = {
|
||||
test_deno: { args: undefined; result: string };
|
||||
open_file: { args: { path: string }; result: void };
|
||||
show_in_folder: { args: { path: string }; result: void };
|
||||
reveal_in_file_manager: { args: { path: string }; result: void };
|
||||
open_downloaded_file: { args: { path: string }; result: void };
|
||||
trash_download_assets: { args: { path: string; partialPaths: string[] }; result: void };
|
||||
start_download: { args: StartDownloadArgs; result: void };
|
||||
start_media_download: { args: StartMediaDownloadArgs; result: void };
|
||||
pause_download: { args: { id: string }; result: void };
|
||||
|
||||
@@ -204,17 +204,22 @@ export const useDownloadStore = create<DownloadState>((set, get) => ({
|
||||
const item = get().downloads.find(d => d.id === id);
|
||||
if (item && item.status === 'downloading') {
|
||||
try {
|
||||
const filepath = item.destination ? `${item.destination}/${item.fileName}` : null;
|
||||
await invoke('remove_download', { id, filepath });
|
||||
// Just cancel the active download via the backend, don't delete files via remove_download
|
||||
await invoke('remove_download', { id, filepath: null });
|
||||
} catch (e) {
|
||||
console.error("Failed to terminate download on deletion:", e);
|
||||
}
|
||||
} else if (item && deleteFile) {
|
||||
}
|
||||
|
||||
if (item && deleteFile) {
|
||||
try {
|
||||
const filepath = item.destination ? `${item.destination}/${item.fileName}` : null;
|
||||
await invoke('remove_download', { id, filepath });
|
||||
if (filepath) {
|
||||
const partialPaths = [`${filepath}.aria2`, `${filepath}.part`];
|
||||
await invoke('trash_download_assets', { path: filepath, partialPaths });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to delete file from disk:", e);
|
||||
console.error("Failed to trash file from disk:", e);
|
||||
}
|
||||
}
|
||||
set((state) => ({
|
||||
|
||||
Reference in New Issue
Block a user