Skip to content

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

fix: handle case where attachment length = 0

thecodrr1f6899afb6e5
diff --git a/apps/web/src/interfaces/fs.js b/apps/web/src/interfaces/fs.js
index b9b49618d..02c73db72 100644
--- a/apps/web/src/interfaces/fs.js
+++ b/apps/web/src/interfaces/fs.js
@@ -284,8 +284,13 @@ async function downloadFile(filename, requestOptions) {
onDownloadProgress: (ev) =>
reportProgress(ev, { type: "download", hash: filename }),
});
+ const contentLength =
+ response.headers["content-length"] || response.headers["Content-Length"];
+ if (!isSuccessStatusCode(response.status) || contentLength === "0") {
+ console.error("Abort: file length is 0.", filename);
+ return false;
+ }
- if (!isSuccessStatusCode(response.status)) return false;
const distributor = new ChunkDistributor(chunkSize + ABYTES);
distributor.fill(new Uint8Array(response.data));
distributor.close();