bulk load db and remove some verbose output, to speed up
This commit is contained in:
parent
c5a7085fda
commit
0e6182b887
@ -76,6 +76,7 @@
|
|||||||
"emoji-regex": "^10.3.0",
|
"emoji-regex": "^10.3.0",
|
||||||
"http-status-codes": "^2.3.0",
|
"http-status-codes": "^2.3.0",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
|
"localforage-getitems": "^1.4.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lucide": "^0.298.0",
|
"lucide": "^0.298.0",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import localforage from "localforage";
|
import localforage from "localforage";
|
||||||
|
import { extendPrototype } from "localforage-getitems";
|
||||||
|
extendPrototype(localforage);
|
||||||
export type LocalForage = typeof localforage;
|
export type LocalForage = typeof localforage;
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import { requireApiVersion, TAbstractFile, TFile, TFolder } from "obsidian";
|
import { requireApiVersion, TAbstractFile, TFile, TFolder } from "obsidian";
|
||||||
@ -434,13 +436,12 @@ export const getAllPrevSyncRecordsByVaultAndProfile = async (
|
|||||||
vaultRandomID: string,
|
vaultRandomID: string,
|
||||||
profileID: string
|
profileID: string
|
||||||
) => {
|
) => {
|
||||||
// console.debug('inside getAllPrevSyncRecordsByVaultAndProfile')
|
|
||||||
const keys = await db.prevSyncRecordsTbl.keys();
|
|
||||||
// console.debug(`inside getAllPrevSyncRecordsByVaultAndProfile, keys=${keys}`)
|
|
||||||
const res: Entity[] = [];
|
const res: Entity[] = [];
|
||||||
for (const key of keys) {
|
const kv: Record<string, Entity | null> =
|
||||||
|
await db.prevSyncRecordsTbl.getItems();
|
||||||
|
for (const key of Object.getOwnPropertyNames(kv)) {
|
||||||
if (key.startsWith(`${vaultRandomID}\t${profileID}\t`)) {
|
if (key.startsWith(`${vaultRandomID}\t${profileID}\t`)) {
|
||||||
const val: Entity | null = await db.prevSyncRecordsTbl.getItem(key);
|
const val = kv[key];
|
||||||
if (val !== null) {
|
if (val !== null) {
|
||||||
res.push(val);
|
res.push(val);
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/sync.ts
14
src/sync.ts
@ -1369,9 +1369,9 @@ export const doActualSync = async (
|
|||||||
|
|
||||||
for (let j = 0; j < operations.length; ++j) {
|
for (let j = 0; j < operations.length; ++j) {
|
||||||
const singleLevelOps = operations[j];
|
const singleLevelOps = operations[j];
|
||||||
console.debug(
|
// console.debug(
|
||||||
`singleLevelOps=${JSON.stringify(singleLevelOps, null, 2)}`
|
// `singleLevelOps=${JSON.stringify(singleLevelOps, null, 2)}`
|
||||||
);
|
// );
|
||||||
if (singleLevelOps === undefined || singleLevelOps === null) {
|
if (singleLevelOps === undefined || singleLevelOps === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1385,9 +1385,9 @@ export const doActualSync = async (
|
|||||||
const key = val.key;
|
const key = val.key;
|
||||||
|
|
||||||
const fn = async () => {
|
const fn = async () => {
|
||||||
console.debug(
|
// console.debug(
|
||||||
`start syncing "${key}" with plan ${JSON.stringify(val)}`
|
// `start syncing "${key}" with plan ${JSON.stringify(val)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (callbackSyncProcess !== undefined) {
|
if (callbackSyncProcess !== undefined) {
|
||||||
await callbackSyncProcess(
|
await callbackSyncProcess(
|
||||||
@ -1412,7 +1412,7 @@ export const doActualSync = async (
|
|||||||
cipher
|
cipher
|
||||||
);
|
);
|
||||||
|
|
||||||
console.debug(`finished ${key}`);
|
// console.debug(`finished ${key}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
queue.add(fn).catch((e) => {
|
queue.add(fn).catch((e) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user