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
mobile: reupload if file size is zero
Ammar Ahmed64d10f5050eb
diff --git a/apps/mobile/app/common/filesystem/download.js b/apps/mobile/app/common/filesystem/download.jsindex 7d92bb27d..5623eae50 100644--- a/apps/mobile/app/common/filesystem/download.js+++ b/apps/mobile/app/common/filesystem/download.js@@ -96,16 +96,22 @@ export async function downloadFile(filename, data, cancelToken) {}export async function getUploadedFileSize(hash) {- const url = `${hosts.API_HOST}/s3?name=${hash}`;- const token = await db.user.tokenManager.getAccessToken();+ try {+ const url = `${hosts.API_HOST}/s3?name=${hash}`;+ const token = await db.user.tokenManager.getAccessToken();- const attachmentInfo = await fetch(url, {- method: "HEAD",- headers: { Authorization: `Bearer ${token}` }- });+ const attachmentInfo = await fetch(url, {+ method: "HEAD",+ headers: { Authorization: `Bearer ${token}` }+ });- const contentLength = parseInt(attachmentInfo.headers?.get("content-length"));- return isNaN(contentLength) ? 0 : contentLength;+ const contentLength = parseInt(+ attachmentInfo.headers?.get("content-length")+ );+ return isNaN(contentLength) ? 0 : contentLength;+ } catch (e) {+ return 0;+ }}export async function checkAttachment(hash) {diff --git a/apps/mobile/app/screens/editor/tiptap/picker.js b/apps/mobile/app/screens/editor/tiptap/picker.jsindex 07f1e2302..a532f07cc 100644--- a/apps/mobile/app/screens/editor/tiptap/picker.js+++ b/apps/mobile/app/screens/editor/tiptap/picker.js@@ -35,6 +35,7 @@ import { FILE_SIZE_LIMIT, IMAGE_SIZE_LIMIT } from "../../../utils/constants";import { eCloseSheet } from "../../../utils/events";import { editorController, editorState } from "./utils";import { useSettingStore } from "../../../stores/use-setting-store";+import filesystem from "../../../common/filesystem";const showEncryptionSheet = (file) => {presentSheet({@@ -270,6 +271,10 @@ export async function attachFile(uri, hash, type, filename, options) {return false;}+ if (!options.reupload && exists) {+ options.reupload = (await filesystem.getUploadedFileSize(hash)) <= 0;+ }+if (!exists || options?.reupload) {let key = await db.attachments.generateKey();encryptionInfo = await Sodium.encryptFile(key, {