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
core: sync attachments before anything else
Abdullah Attad59e0d9ee280
diff --git a/packages/core/src/api/sync/collector.js b/packages/core/src/api/sync/collector.jsindex 64dfc0c24..7c83c8dc2 100644--- a/packages/core/src/api/sync/collector.js+++ b/packages/core/src/api/sync/collector.js@@ -43,12 +43,22 @@ class Collector {async *collect(chunkSize, lastSyncedTimestamp, isForceSync) {const key = await this._db.user.getEncryptionKey();- for (const itemType in SYNC_COLLECTIONS_MAP) {- const collectionKey = SYNC_COLLECTIONS_MAP[itemType];++ const attachments = await this.prepareChunk(+ this._db.attachments.syncable,+ lastSyncedTimestamp,+ isForceSync,+ key,+ "attachment"+ );+ if (attachments) yield attachments;++ for (const itemType in ASYNC_COLLECTIONS_MAP) {+ const collectionKey = ASYNC_COLLECTIONS_MAP[itemType];const collection = this._db[collectionKey]._collection;- for (const chunk of collection.iterateSync(chunkSize)) {+ for await (const chunk of collection.iterate(chunkSize)) {const items = await this.prepareChunk(- chunk,+ chunk.map((item) => item[1]),lastSyncedTimestamp,isForceSync,key,@@ -59,12 +69,12 @@ class Collector {}}- for (const itemType in ASYNC_COLLECTIONS_MAP) {- const collectionKey = ASYNC_COLLECTIONS_MAP[itemType];+ for (const itemType in SYNC_COLLECTIONS_MAP) {+ const collectionKey = SYNC_COLLECTIONS_MAP[itemType];const collection = this._db[collectionKey]._collection;- for await (const chunk of collection.iterate(chunkSize)) {+ for (const chunk of collection.iterateSync(chunkSize)) {const items = await this.prepareChunk(- chunk.map((item) => item[1]),+ chunk,lastSyncedTimestamp,isForceSync,key,@@ -75,15 +85,6 @@ class Collector {}}- const attachments = await this.prepareChunk(- this._db.attachments.syncable,- lastSyncedTimestamp,- isForceSync,- key,- "attachment"- );- if (attachments) yield attachments;-const settings = await this.prepareChunk([this._db.settings.raw],lastSyncedTimestamp,