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
fix: return undefined instead of throwing if file not found
thecodrrf012656167fa
diff --git a/apps/web/packages/streamablefs/index.ts b/apps/web/packages/streamablefs/index.tsindex eeacc0e65..acc2a2b4e 100644--- a/apps/web/packages/streamablefs/index.ts+++ b/apps/web/packages/streamablefs/index.ts@@ -33,9 +33,9 @@ export class StreamableFS implements IStreamableFS {return new FileHandle(this.storage, file);}- async readFile(filename: string): Promise<FileHandle> {+ async readFile(filename: string): Promise<FileHandle | undefined> {const file = await this.storage.getItem<File>(filename);- if (!file) throw new Error("File does not exist.");+ if (!file) return undefined;return new FileHandle(this.storage, file);}@@ -44,9 +44,10 @@ export class StreamableFS implements IStreamableFS {return !!file;}- async deleteFile(filename: string) {+ async deleteFile(filename: string): Promise<boolean> {const handle = await this.readFile(filename);- if (!handle) return;+ if (!handle) return true;await handle.delete();+ return true;}}diff --git a/apps/web/packages/streamablefs/src/interfaces.ts b/apps/web/packages/streamablefs/src/interfaces.tsindex e4a4beb82..8e15e01a1 100644--- a/apps/web/packages/streamablefs/src/interfaces.ts+++ b/apps/web/packages/streamablefs/src/interfaces.ts@@ -2,7 +2,7 @@ import FileHandle from "./filehandle";export interface IStreamableFS {createFile(filename: string, size: number, type: string): Promise<FileHandle>;- readFile(filename: string): Promise<FileHandle>;+ readFile(filename: string): Promise<FileHandle | undefined>;exists(filename: string): Promise<boolean>;- deleteFile(filename: string): Promise<void>;+ deleteFile(filename: string): Promise<boolean>;}