show progress
This commit is contained in:
parent
e7c24b55a3
commit
c637038d95
21
src/main.ts
21
src/main.ts
@ -64,6 +64,7 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
syncStatus: SyncStatusType;
|
||||
oauth2Info: OAuth2Info;
|
||||
currLogLevel: string;
|
||||
currSyncMsg?: string;
|
||||
|
||||
async onload() {
|
||||
log.info(`loading plugin ${this.manifest.id}`);
|
||||
@ -76,6 +77,8 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
revokeAuthSetting: undefined,
|
||||
}; // init
|
||||
|
||||
this.currSyncMsg = "";
|
||||
|
||||
await this.loadSettings();
|
||||
|
||||
if (this.settings.currLogLevel !== undefined) {
|
||||
@ -282,6 +285,9 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
new Notice(
|
||||
`Remotely Save already running in stage ${this.syncStatus}!`
|
||||
);
|
||||
if (this.currSyncMsg !== undefined && this.currSyncMsg !== "") {
|
||||
new Notice(this.currSyncMsg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -349,10 +355,13 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
this.db,
|
||||
this.app.vault,
|
||||
syncPlan,
|
||||
this.settings.password
|
||||
this.settings.password,
|
||||
(i: number, totalCount: number, pathName: string, decision: string) =>
|
||||
self.setCurrSyncMsg(i, totalCount, pathName, decision)
|
||||
);
|
||||
|
||||
new Notice("7/7 Remotely Save finish!");
|
||||
this.currSyncMsg = "";
|
||||
this.syncStatus = "finish";
|
||||
this.syncStatus = "idle";
|
||||
} catch (error) {
|
||||
@ -479,4 +488,14 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
destroyDBs() {
|
||||
/* destroyDBs(this.db); */
|
||||
}
|
||||
|
||||
async setCurrSyncMsg(
|
||||
i: number,
|
||||
totalCount: number,
|
||||
pathName: string,
|
||||
decision: string
|
||||
) {
|
||||
const msg = `${i}/${totalCount}, ${decision}, ${pathName}`;
|
||||
this.currSyncMsg = msg;
|
||||
}
|
||||
}
|
||||
|
||||
11
src/sync.ts
11
src/sync.ts
@ -567,16 +567,23 @@ export const doActualSync = async (
|
||||
db: InternalDBs,
|
||||
vault: Vault,
|
||||
syncPlan: SyncPlanType,
|
||||
password: string = ""
|
||||
password: string = "",
|
||||
callbackSyncProcess?: any
|
||||
) => {
|
||||
const keyStates = syncPlan.mixedStates;
|
||||
const foldersCreatedBefore = new Set<string>();
|
||||
let i = 0;
|
||||
const totalCount = Object.keys(keyStates).length || 0;
|
||||
for (const [k, v] of Object.entries(keyStates).sort(
|
||||
([k1, v1], [k2, v2]) => k2.length - k1.length
|
||||
)) {
|
||||
i += 1;
|
||||
const k2 = k as string;
|
||||
const v2 = v as FileOrFolderMixedState;
|
||||
log.debug(`start syncing "${k2}" with plan ${JSON.stringify(v2)}`);
|
||||
if (callbackSyncProcess !== undefined) {
|
||||
await callbackSyncProcess(i, totalCount, k2, v2.decision);
|
||||
}
|
||||
await dispatchOperationToActual(
|
||||
k2,
|
||||
v2,
|
||||
@ -586,7 +593,7 @@ export const doActualSync = async (
|
||||
password,
|
||||
foldersCreatedBefore
|
||||
);
|
||||
// log.info(`finished ${k}, with ${setToString(foldersCreatedBefore)}`);
|
||||
log.info(`finished ${k2}`);
|
||||
}
|
||||
// await Promise.all(
|
||||
// Object.entries(keyStates)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user