AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(desktop): suppress false WeChat import failure from rejected URL
tianma-ife905f5a1535e
diff --git a/apps/desktop/src/main/wechat-share-import.mjs b/apps/desktop/src/main/wechat-share-import.mjsindex 1b62d010..6c44802c 100644--- a/apps/desktop/src/main/wechat-share-import.mjs+++ b/apps/desktop/src/main/wechat-share-import.mjs@@ -156,7 +156,11 @@ export const createWeChatShareController = ({if (preparedDirectory) await rm(preparedDirectory, { recursive: true, force: true }).catch(() => {});const reason = error instanceof WeChatArchiveError ? error.code : "failed";failedPaths.add(requestedPath);- sendToRenderer({ ok: false, reason: reason === "unrecognized" ? "unrecognized" : "failed" });+ // A stale or malformed protocol URL may arrive before the incoming-folder+ // scan finds the actual share. It is not a failed save attempt.+ if (reason !== "rejected-path") {+ sendToRenderer({ ok: false, reason: reason === "unrecognized" ? "unrecognized" : "failed" });+ }void writeDiagnostic("wechat-import.rejected", { reason });} finally {inFlightPaths.delete(requestedPath);diff --git a/apps/desktop/src/main/wechat-share-import.test.mjs b/apps/desktop/src/main/wechat-share-import.test.mjsindex f6e8dedd..0d981a16 100644--- a/apps/desktop/src/main/wechat-share-import.test.mjs+++ b/apps/desktop/src/main/wechat-share-import.test.mjs@@ -129,10 +129,50 @@ describe("WeChat share handoff", () => {sendToRenderer: (payload) => sent.push(payload),});await controller.importFromProtocolUrl(`edgeever://wechat-import?path=${encodeURIComponent(outside)}`);- expect(sent[0]).toEqual({ ok: false, reason: "failed" });+ expect(sent).toHaveLength(0);expect((await readFile(outside)).toString()).toBe("secret");});+ test("a rejected protocol path does not report failure before a valid share is scanned", async () => {+ const root = await mkdtemp(join(tmpdir(), "edgeever-wechat-share-"));+ roots.push(root);+ const downloads = join(root, "Downloads");+ const batch = join(downloads, WECHAT_INCOMING_DIRECTORY_NAME, "batch");+ await mkdir(batch, { recursive: true });+ const zipPath = join(batch, "聊天记录.zip");+ await writeFile(zipPath, zipOf("聊天记录.txt", "·鱼\n2026年9月22日 22:15\n你好\n", "附件/readme.txt", "hello"));+ const sent = [];+ const controller = createWeChatShareController({+ downloadsPath: () => downloads,+ tempPath: () => join(root, "temp"),+ sendToRenderer: (payload) => sent.push(payload),+ });+ await controller.importFromProtocolUrl(`edgeever://wechat-import?path=${encodeURIComponent(join(root, "stale.zip"))}`);+ await controller.importPending();+ expect(sent).toHaveLength(1);+ expect(sent[0].ok).toBe(true);+ await controller.finish(sent[0].importId, true);+ await expect(stat(zipPath)).rejects.toThrow();+ });++ test("reports a recognized incoming path with an invalid archive", async () => {+ const root = await mkdtemp(join(tmpdir(), "edgeever-wechat-share-"));+ roots.push(root);+ const downloads = join(root, "Downloads");+ const batch = join(downloads, WECHAT_INCOMING_DIRECTORY_NAME, "batch");+ await mkdir(batch, { recursive: true });+ const zipPath = join(batch, "broken.zip");+ await writeFile(zipPath, "not a zip");+ const sent = [];+ const controller = createWeChatShareController({+ downloadsPath: () => downloads,+ tempPath: () => join(root, "temp"),+ sendToRenderer: (payload) => sent.push(payload),+ });+ await controller.importPending();+ expect(sent).toEqual([{ ok: false, reason: "failed" }]);+ });+test("picks up a completed share without a protocol URL and ignores a duplicate URL", async () => {const root = await mkdtemp(join(tmpdir(), "edgeever-wechat-share-"));roots.push(root);