Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe572b41c9 | ||
|
|
ca5ca5f576 | ||
|
|
0e6182b887 | ||
|
|
c5a7085fda | ||
|
|
640f1e56f1 |
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "remotely-save",
|
"id": "remotely-save",
|
||||||
"name": "Remotely Save",
|
"name": "Remotely Save",
|
||||||
"version": "0.4.15",
|
"version": "0.4.16",
|
||||||
"minAppVersion": "0.13.21",
|
"minAppVersion": "0.13.21",
|
||||||
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
|
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
|
||||||
"author": "fyears",
|
"author": "fyears",
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "remotely-save",
|
"id": "remotely-save",
|
||||||
"name": "Remotely Save",
|
"name": "Remotely Save",
|
||||||
"version": "0.4.15",
|
"version": "0.4.16",
|
||||||
"minAppVersion": "0.13.21",
|
"minAppVersion": "0.13.21",
|
||||||
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
|
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
|
||||||
"author": "fyears",
|
"author": "fyears",
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "remotely-save",
|
"name": "remotely-save",
|
||||||
"version": "0.4.15",
|
"version": "0.4.16",
|
||||||
"description": "This is yet another sync plugin for Obsidian app.",
|
"description": "This is yet another sync plugin for Obsidian app.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev2": "node esbuild.config.mjs --watch",
|
"dev2": "node esbuild.config.mjs --watch",
|
||||||
@@ -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",
|
||||||
|
|||||||
+6
-5
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-27
@@ -221,14 +221,19 @@ const fullfillMTimeOfRemoteEntityInplace = (
|
|||||||
remote: Entity,
|
remote: Entity,
|
||||||
mtimeCli?: number
|
mtimeCli?: number
|
||||||
) => {
|
) => {
|
||||||
|
// TODO:
|
||||||
|
// on 20240405, we find that dropbox's mtimeCli is not updated
|
||||||
|
// if the content is not updated even the time is updated...
|
||||||
|
// so we do not check remote.mtimeCli for now..
|
||||||
if (
|
if (
|
||||||
mtimeCli !== undefined &&
|
mtimeCli !== undefined &&
|
||||||
mtimeCli > 0 &&
|
mtimeCli > 0 /* &&
|
||||||
(remote.mtimeCli === undefined ||
|
(remote.mtimeCli === undefined ||
|
||||||
remote.mtimeCli <= 0 ||
|
remote.mtimeCli <= 0 ||
|
||||||
(remote.mtimeSvr !== undefined &&
|
(remote.mtimeSvr !== undefined &&
|
||||||
remote.mtimeSvr > 0 &&
|
remote.mtimeSvr > 0 &&
|
||||||
remote.mtimeCli >= remote.mtimeSvr))
|
remote.mtimeCli >= remote.mtimeSvr))
|
||||||
|
*/
|
||||||
) {
|
) {
|
||||||
remote.mtimeCli = mtimeCli;
|
remote.mtimeCli = mtimeCli;
|
||||||
}
|
}
|
||||||
@@ -1120,26 +1125,31 @@ const dispatchOperationToActualV3 = async (
|
|||||||
r.decision === "conflict_created_then_do_nothing" ||
|
r.decision === "conflict_created_then_do_nothing" ||
|
||||||
r.decision === "folder_existed_both_then_do_nothing"
|
r.decision === "folder_existed_both_then_do_nothing"
|
||||||
) {
|
) {
|
||||||
// !! we need to upsert the record,
|
// !! we MIGHT need to upsert the record,
|
||||||
// so that next time we can determine the change delta
|
// so that next time we can determine the change delta
|
||||||
// if we have prevSync, we store it because it should keep all necessary info
|
|
||||||
let entity = r.prevSync;
|
if (r.prevSync !== undefined) {
|
||||||
// if we don't have prevSync, we use remote entity AND local mtime
|
// if we have prevSync,
|
||||||
// as if it is "uploaded"
|
// we don't need to do anything, because the record is already there!
|
||||||
if (entity === undefined && r.remote !== undefined) {
|
} else {
|
||||||
entity = await decryptRemoteEntityInplace(r.remote, cipher);
|
// if we don't have prevSync, we use remote entity AND local mtime
|
||||||
entity = await fullfillMTimeOfRemoteEntityInplace(
|
// as if it is "uploaded"
|
||||||
entity,
|
if (r.remote !== undefined) {
|
||||||
r.local?.mtimeCli
|
let entity = await decryptRemoteEntityInplace(r.remote, cipher);
|
||||||
);
|
entity = await fullfillMTimeOfRemoteEntityInplace(
|
||||||
}
|
entity,
|
||||||
if (entity !== undefined) {
|
r.local?.mtimeCli
|
||||||
await upsertPrevSyncRecordByVaultAndProfile(
|
);
|
||||||
db,
|
|
||||||
vaultRandomID,
|
if (entity !== undefined) {
|
||||||
profileID,
|
await upsertPrevSyncRecordByVaultAndProfile(
|
||||||
entity
|
db,
|
||||||
);
|
vaultRandomID,
|
||||||
|
profileID,
|
||||||
|
entity
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
r.decision === "local_is_modified_then_push" ||
|
r.decision === "local_is_modified_then_push" ||
|
||||||
@@ -1166,8 +1176,13 @@ const dispatchOperationToActualV3 = async (
|
|||||||
cipher,
|
cipher,
|
||||||
r.local!.keyEnc
|
r.local!.keyEnc
|
||||||
);
|
);
|
||||||
|
// console.debug(`after uploadToRemote`);
|
||||||
|
// console.debug(`entity=${JSON.stringify(entity,null,2)}`)
|
||||||
|
// console.debug(`mtimeCli=${mtimeCli}`)
|
||||||
await decryptRemoteEntityInplace(entity, cipher);
|
await decryptRemoteEntityInplace(entity, cipher);
|
||||||
|
// console.debug(`after dec, entity=${JSON.stringify(entity,null,2)}`)
|
||||||
await fullfillMTimeOfRemoteEntityInplace(entity, mtimeCli);
|
await fullfillMTimeOfRemoteEntityInplace(entity, mtimeCli);
|
||||||
|
// console.debug(`after fullfill, entity=${JSON.stringify(entity,null,2)}`)
|
||||||
await upsertPrevSyncRecordByVaultAndProfile(
|
await upsertPrevSyncRecordByVaultAndProfile(
|
||||||
db,
|
db,
|
||||||
vaultRandomID,
|
vaultRandomID,
|
||||||
@@ -1364,9 +1379,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;
|
||||||
}
|
}
|
||||||
@@ -1380,9 +1395,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(
|
||||||
@@ -1407,7 +1422,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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user