Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: check if file exists before starting upload

Abdullah Atta76b3dd1f9693
diff --git a/apps/web/src/interfaces/fs.ts b/apps/web/src/interfaces/fs.ts
index bdb9f6391..b0bdf95ac 100644
--- a/apps/web/src/interfaces/fs.ts
+++ b/apps/web/src/interfaces/fs.ts
@@ -226,8 +226,10 @@ type UploadAdditionalData = {
async function uploadFile(filename: string, requestOptions: RequestOptions) {
const fileHandle = await streamablefs.readFile(filename);
- if (!fileHandle)
- throw new Error(`File stream not found. (File hash: ${filename})`);
+ if (!fileHandle || !(await exists(filename)))
+ throw new Error(
+ `File is corrupt or missing data. Please upload the file again. (File hash: ${filename})`
+ );
try {
if (fileHandle.file.additionalData?.uploaded) {
await checkUpload(filename);