fail statusbar
This commit is contained in:
parent
2a3df8ab53
commit
67467a5034
@ -53,6 +53,7 @@
|
|||||||
"statusbar_time_lessminute": "Synced last minute ago",
|
"statusbar_time_lessminute": "Synced last minute ago",
|
||||||
"statusbar_lastsync": "Synced {{time}} ago",
|
"statusbar_lastsync": "Synced {{time}} ago",
|
||||||
"statusbar_syncing": "Syncing...",
|
"statusbar_syncing": "Syncing...",
|
||||||
|
"statusbar_failed": "Last sync failed",
|
||||||
"statusbar_now": "Synced just now",
|
"statusbar_now": "Synced just now",
|
||||||
"statusbar_lastsync_label": "Last successful Sync on {{date}}",
|
"statusbar_lastsync_label": "Last successful Sync on {{date}}",
|
||||||
"statusbar_lastsync_never": "Never Synced",
|
"statusbar_lastsync_never": "Never Synced",
|
||||||
|
|||||||
@ -53,6 +53,7 @@
|
|||||||
"statusbar_time_lessminute": "一分钟之内同步",
|
"statusbar_time_lessminute": "一分钟之内同步",
|
||||||
"statusbar_lastsync": "上一次同步于:{{time}}",
|
"statusbar_lastsync": "上一次同步于:{{time}}",
|
||||||
"statusbar_syncing": "正在同步",
|
"statusbar_syncing": "正在同步",
|
||||||
|
"statusbar_failed": "上次同步失败了",
|
||||||
"statusbar_now": "刚同步完",
|
"statusbar_now": "刚同步完",
|
||||||
"statusbar_lastsync_label": "上一次同步于:{{date}}",
|
"statusbar_lastsync_label": "上一次同步于:{{date}}",
|
||||||
"statusbar_lastsync_never": "没触发过同步",
|
"statusbar_lastsync_never": "没触发过同步",
|
||||||
|
|||||||
@ -52,6 +52,7 @@
|
|||||||
"statusbar_time_lessminute": "一分鐘之內同步",
|
"statusbar_time_lessminute": "一分鐘之內同步",
|
||||||
"statusbar_lastsync": "上一次同步於:{{time}}",
|
"statusbar_lastsync": "上一次同步於:{{time}}",
|
||||||
"statusbar_syncing": "正在同步",
|
"statusbar_syncing": "正在同步",
|
||||||
|
"statusbar_failed": "上次同步失敗了",
|
||||||
"statusbar_now": "剛同步完",
|
"statusbar_now": "剛同步完",
|
||||||
"statusbar_lastsync_label": "上一次同步於:{{date}}",
|
"statusbar_lastsync_label": "上一次同步於:{{date}}",
|
||||||
"statusbar_lastsync_never": "沒觸發過同步",
|
"statusbar_lastsync_never": "沒觸發過同步",
|
||||||
|
|||||||
15
src/main.ts
15
src/main.ts
@ -337,11 +337,15 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const statusBarFunc = async (s: SyncTriggerSourceType, step: number) => {
|
const statusBarFunc = async (
|
||||||
|
s: SyncTriggerSourceType,
|
||||||
|
step: number,
|
||||||
|
everythingOk: boolean
|
||||||
|
) => {
|
||||||
if (step === 1) {
|
if (step === 1) {
|
||||||
// change status to "syncing..." on statusbar
|
// change status to "syncing..." on statusbar
|
||||||
this.updateLastSuccessSyncMsg(-1);
|
this.updateLastSuccessSyncMsg(-1);
|
||||||
} else if (step === 8) {
|
} else if (step === 8 && everythingOk) {
|
||||||
const lastSuccessSyncMillis = Date.now();
|
const lastSuccessSyncMillis = Date.now();
|
||||||
await upsertLastSuccessSyncTimeByVault(
|
await upsertLastSuccessSyncTimeByVault(
|
||||||
this.db,
|
this.db,
|
||||||
@ -349,6 +353,8 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
lastSuccessSyncMillis
|
lastSuccessSyncMillis
|
||||||
);
|
);
|
||||||
this.updateLastSuccessSyncMsg(lastSuccessSyncMillis);
|
this.updateLastSuccessSyncMsg(lastSuccessSyncMillis);
|
||||||
|
} else if (!everythingOk) {
|
||||||
|
this.updateLastSuccessSyncMsg(-2); // magic number
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1266,6 +1272,11 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
lastSyncMsg = t("statusbar_syncing");
|
lastSyncMsg = t("statusbar_syncing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastSuccessSyncMillis !== undefined && lastSuccessSyncMillis === -2) {
|
||||||
|
lastSyncMsg = t("statusbar_failed");
|
||||||
|
lastSyncLabelMsg = t("statusbar_failed");
|
||||||
|
}
|
||||||
|
|
||||||
if (lastSuccessSyncMillis !== undefined && lastSuccessSyncMillis > 0) {
|
if (lastSuccessSyncMillis !== undefined && lastSuccessSyncMillis > 0) {
|
||||||
const deltaTime = Date.now() - lastSuccessSyncMillis;
|
const deltaTime = Date.now() - lastSuccessSyncMillis;
|
||||||
|
|
||||||
|
|||||||
27
src/sync.ts
27
src/sync.ts
@ -1283,26 +1283,32 @@ export async function syncer(
|
|||||||
notifyFunc?: (s: SyncTriggerSourceType, step: number) => Promise<any>,
|
notifyFunc?: (s: SyncTriggerSourceType, step: number) => Promise<any>,
|
||||||
errNotifyFunc?: (s: SyncTriggerSourceType, error: Error) => Promise<any>,
|
errNotifyFunc?: (s: SyncTriggerSourceType, error: Error) => Promise<any>,
|
||||||
ribboonFunc?: (s: SyncTriggerSourceType, step: number) => Promise<any>,
|
ribboonFunc?: (s: SyncTriggerSourceType, step: number) => Promise<any>,
|
||||||
statusBarFunc?: (s: SyncTriggerSourceType, step: number) => any,
|
statusBarFunc?: (
|
||||||
|
s: SyncTriggerSourceType,
|
||||||
|
step: number,
|
||||||
|
everythingOk: boolean
|
||||||
|
) => any,
|
||||||
callbackSyncProcess?: any
|
callbackSyncProcess?: any
|
||||||
) {
|
) {
|
||||||
console.info(`startting sync.`);
|
console.info(`startting sync.`);
|
||||||
markIsSyncingFunc(true);
|
markIsSyncingFunc(true);
|
||||||
|
|
||||||
|
let everythingOk = true;
|
||||||
|
|
||||||
let step = 0; // dry mode only
|
let step = 0; // dry mode only
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
|
|
||||||
step = 1;
|
step = 1;
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
profiler.insert("start big sync func");
|
profiler.insert("start big sync func");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
step = 2;
|
step = 2;
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
if (fsEncrypt.innerFs !== fsRemote) {
|
if (fsEncrypt.innerFs !== fsRemote) {
|
||||||
throw Error(`your enc should has inner of the remote`);
|
throw Error(`your enc should has inner of the remote`);
|
||||||
}
|
}
|
||||||
@ -1317,7 +1323,7 @@ export async function syncer(
|
|||||||
step = 3;
|
step = 3;
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
const remoteEntityList = await fsEncrypt.walk();
|
const remoteEntityList = await fsEncrypt.walk();
|
||||||
// console.debug(`remoteEntityList:`);
|
// console.debug(`remoteEntityList:`);
|
||||||
// console.debug(remoteEntityList);
|
// console.debug(remoteEntityList);
|
||||||
@ -1326,7 +1332,7 @@ export async function syncer(
|
|||||||
step = 4;
|
step = 4;
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
const localEntityList = await fsLocal.walk();
|
const localEntityList = await fsLocal.walk();
|
||||||
// console.debug(`localEntityList:`);
|
// console.debug(`localEntityList:`);
|
||||||
// console.debug(localEntityList);
|
// console.debug(localEntityList);
|
||||||
@ -1335,7 +1341,7 @@ export async function syncer(
|
|||||||
step = 5;
|
step = 5;
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
const prevSyncEntityList = await getAllPrevSyncRecordsByVaultAndProfile(
|
const prevSyncEntityList = await getAllPrevSyncRecordsByVaultAndProfile(
|
||||||
db,
|
db,
|
||||||
vaultRandomID,
|
vaultRandomID,
|
||||||
@ -1348,7 +1354,7 @@ export async function syncer(
|
|||||||
step = 6;
|
step = 6;
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
let mixedEntityMappings = await ensembleMixedEnties(
|
let mixedEntityMappings = await ensembleMixedEnties(
|
||||||
localEntityList,
|
localEntityList,
|
||||||
prevSyncEntityList,
|
prevSyncEntityList,
|
||||||
@ -1391,7 +1397,7 @@ export async function syncer(
|
|||||||
if (triggerSource !== "dry") {
|
if (triggerSource !== "dry") {
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
await doActualSync(
|
await doActualSync(
|
||||||
mixedEntityMappings,
|
mixedEntityMappings,
|
||||||
fsLocal,
|
fsLocal,
|
||||||
@ -1409,13 +1415,14 @@ export async function syncer(
|
|||||||
} else {
|
} else {
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
profiler.insert(
|
profiler.insert(
|
||||||
`finish step${step} (skip actual sync because of dry run)`
|
`finish step${step} (skip actual sync because of dry run)`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
profiler.insert("start error branch");
|
profiler.insert("start error branch");
|
||||||
|
everythingOk = false;
|
||||||
await errNotifyFunc?.(triggerSource, error as Error);
|
await errNotifyFunc?.(triggerSource, error as Error);
|
||||||
|
|
||||||
profiler.insert("finish error branch");
|
profiler.insert("finish error branch");
|
||||||
@ -1429,7 +1436,7 @@ export async function syncer(
|
|||||||
step = 8;
|
step = 8;
|
||||||
await notifyFunc?.(triggerSource, step);
|
await notifyFunc?.(triggerSource, step);
|
||||||
await ribboonFunc?.(triggerSource, step);
|
await ribboonFunc?.(triggerSource, step);
|
||||||
await statusBarFunc?.(triggerSource, step);
|
await statusBarFunc?.(triggerSource, step, everythingOk);
|
||||||
|
|
||||||
console.info(`endding sync.`);
|
console.info(`endding sync.`);
|
||||||
markIsSyncingFunc(false);
|
markIsSyncingFunc(false);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user