A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
desktop: handle errors thrown during backup creation
Abdullah Atta17bfe4e0754e
diff --git a/apps/web/src/common/desktop-bridge/index.desktop.ts b/apps/web/src/common/desktop-bridge/index.desktop.tsindex 245a74bca..89bc30085 100644--- a/apps/web/src/common/desktop-bridge/index.desktop.ts+++ b/apps/web/src/common/desktop-bridge/index.desktop.ts@@ -23,6 +23,7 @@ import type { AppRouter } from "@notesnook/desktop";import { AppEventManager, AppEvents } from "../app-events";import { TaskScheduler } from "../../utils/task-scheduler";import { checkForUpdate } from "../../utils/updater";+import { showToast } from "../../utils/toast";export const desktop = createTRPCProxyClient<AppRouter>({links: [ipcLink()]@@ -77,18 +78,23 @@ function attachListener(event: string) {}export async function createWritableStream(path: string) {- const resolvedPath = await desktop.integration.resolvePath.query({- filePath: path- });- if (!resolvedPath) throw new Error("invalid path.");- const { mkdirSync, createWriteStream }: typeof import("fs") = require("fs");- const { dirname }: typeof import("path") = require("path");- const { Writable } = require("stream");-- mkdirSync(dirname(resolvedPath), { recursive: true });- return new WritableStream(- Writable.toWeb(- createWriteStream(resolvedPath, { encoding: "utf-8" })- ).getWriter()- );+ try {+ const resolvedPath = await desktop.integration.resolvePath.query({+ filePath: path+ });+ if (!resolvedPath) throw new Error("invalid path.");+ const { mkdirSync, createWriteStream }: typeof import("fs") = require("fs");+ const { dirname }: typeof import("path") = require("path");+ const { Writable } = require("stream");++ mkdirSync(dirname(resolvedPath), { recursive: true });+ return new WritableStream(+ Writable.toWeb(+ createWriteStream(resolvedPath, { encoding: "utf-8" })+ ).getWriter()+ );+ } catch (ex) {+ console.error(ex);+ if (ex instanceof Error) showToast("error", ex.message);+ }}