Move workspace file work off the main thread and delete to the trash
Run the blocking workspace commands on the blocking thread pool. Tauri runs a synchronous command on the main thread, so a long search or copy froze every window. Command names, arguments, and results do not change. Send each workspace-event only to the windows that have its root open. The frontend listens with its window label as the target. Do not send access events, because the frontend ignores them. Drop watchers after the state lock is released, because a macOS watcher waits for its thread when it stops. Fix these defects. Each fix has a Rust test: - A rename that changes only the letter case works on case-insensitive volumes. - New files publish with a move that never replaces a file: MoveFileExW on Windows, renameat2 or renamex_np on Linux and macOS, then a hard link, then create_new. exFAT, FAT32, and many network mounts now work. The Windows save recovery uses the same move. - On macOS and Linux, existing names with a colon stay usable. New names reject the characters that Windows does not allow, on every platform. - workspace_read_data_url checks the size before it reads the file. - workspace_write_bytes uses the atomic writer. Its only caller writes new names, so it gets no conflict check. - Delete and rename act on a link itself, not on its target. Delete now moves items to the system trash. One file moves without a confirmation. A folder or several items need one. Shift+Delete and "Delete permanently" keep the permanent delete with its confirmation. Windows drives without a Recycle Bin give an error instead of a silent permanent delete. The smoke test for tree actions now checks this behavior. The user guide describes it and the new-name rule.
This commit is contained in:
@@ -96,6 +96,7 @@ await runSmoke("tree/actions", async ({ page }) => {
|
||||
await page.keyboard.press("Escape");
|
||||
console.log("PASS: selection, clipboard paths, marks, copies, reveal, and single-item menus");
|
||||
|
||||
// Delete moves items to the trash (`permanent: false`). Several items still need one confirmation.
|
||||
await reset();
|
||||
await selectFiles();
|
||||
await page.evaluate(() => { window.__TEST__.answer = "Cancel"; });
|
||||
@@ -106,11 +107,43 @@ await runSmoke("tree/actions", async ({ page }) => {
|
||||
await row("c.md").click({ modifiers: ["Control"] });
|
||||
await action("a.md", "Delete (3)");
|
||||
await row("c.md").waitFor({ state: "detached" });
|
||||
assert.deepEqual((await calls("workspace_delete")).map(args => args.rel), ["a.md", "b.md", "c.md"]);
|
||||
assert.deepEqual(await calls("workspace_delete"), ["a.md", "b.md", "c.md"].map(rel => ({ rel, permanent: false })));
|
||||
assert.match(await page.locator(".tree .error").textContent(), /a.md: Access denied/);
|
||||
// A failed move to the trash offers a permanent delete only through Shift+Delete.
|
||||
assert.match(await page.locator(".tree .error").textContent(), /press Shift\+Delete/);
|
||||
assert.deepEqual(await selected(), ["a.md"]);
|
||||
console.log("PASS: cancellation, one confirmation per batch, partial failure, and selection after deletion");
|
||||
|
||||
// Changed for the move to the trash: one file needs no confirmation. A permanent delete always asks.
|
||||
await reset();
|
||||
await action("c.md", "Delete");
|
||||
await row("c.md").waitFor({ state: "detached" });
|
||||
assert.deepEqual(await calls("workspace_delete"), [{ rel: "c.md", permanent: false }]);
|
||||
assert.equal((await calls("plugin:dialog|message")).length, 0);
|
||||
await page.evaluate(() => { window.__TEST__.answer = "Cancel"; });
|
||||
await action("b.md", "Delete permanently");
|
||||
assert.equal((await calls("plugin:dialog|message")).length, 1);
|
||||
assert.equal((await calls("workspace_delete")).length, 1);
|
||||
await page.evaluate(() => { window.__TEST__.answer = "Ok"; });
|
||||
await action("b.md", "Delete permanently");
|
||||
await row("b.md").waitFor({ state: "detached" });
|
||||
assert.deepEqual((await calls("workspace_delete")).at(-1), { rel: "b.md", permanent: true });
|
||||
console.log("PASS: one file moves to the trash without confirmation, and a permanent delete asks first");
|
||||
|
||||
await reset();
|
||||
await row("a.md").click();
|
||||
await row("a.md").focus();
|
||||
await page.keyboard.press("Delete");
|
||||
await row("a.md").waitFor({ state: "detached" });
|
||||
assert.deepEqual(await calls("workspace_delete"), [{ rel: "a.md", permanent: false }]);
|
||||
await row("b.md").click();
|
||||
await row("b.md").focus();
|
||||
await page.keyboard.press("Shift+Delete");
|
||||
await row("b.md").waitFor({ state: "detached" });
|
||||
assert.deepEqual((await calls("workspace_delete")).at(-1), { rel: "b.md", permanent: true });
|
||||
assert.equal((await calls("plugin:dialog|message")).length, 1);
|
||||
console.log("PASS: Delete moves the selection to the trash, and Shift+Delete deletes it permanently after confirmation");
|
||||
|
||||
await reset();
|
||||
await row("notes").click();
|
||||
await row("notes/nested").click();
|
||||
|
||||
Reference in New Issue
Block a user