From 91af2c849f76ada2aee92cced48328a4c2cd51fa Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sat, 22 Jan 2022 17:17:53 +0800 Subject: [PATCH] revert main.ts after debugging --- src/main.ts | 100 ++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/main.ts b/src/main.ts index a8dbb0b..ee84639 100644 --- a/src/main.ts +++ b/src/main.ts @@ -143,61 +143,61 @@ export default class RemotelySavePlugin extends Plugin { const remoteRsp = await client.listFromRemote(); log.info(remoteRsp); - // getNotice("3/7 Starting to fetch local meta data."); - // this.syncStatus = "getting_local_meta"; - // const local = this.app.vault.getAllLoadedFiles(); - // const localHistory = await loadDeleteRenameHistoryTableByVault( - // this.db, - // this.settings.vaultRandomID - // ); - // // log.info(local); - // // log.info(localHistory); + getNotice("3/7 Starting to fetch local meta data."); + this.syncStatus = "getting_local_meta"; + const local = this.app.vault.getAllLoadedFiles(); + const localHistory = await loadDeleteRenameHistoryTableByVault( + this.db, + this.settings.vaultRandomID + ); + // log.info(local); + // log.info(localHistory); - // getNotice("4/7 Checking password correct or not."); - // this.syncStatus = "checking_password"; - // const passwordCheckResult = await isPasswordOk( - // remoteRsp.Contents, - // this.settings.password - // ); - // if (!passwordCheckResult.ok) { - // getNotice("something goes wrong while checking password"); - // throw Error(passwordCheckResult.reason); - // } + getNotice("4/7 Checking password correct or not."); + this.syncStatus = "checking_password"; + const passwordCheckResult = await isPasswordOk( + remoteRsp.Contents, + this.settings.password + ); + if (!passwordCheckResult.ok) { + getNotice("something goes wrong while checking password"); + throw Error(passwordCheckResult.reason); + } - // getNotice("5/7 Starting to generate sync plan."); - // this.syncStatus = "generating_plan"; - // const syncPlan = await getSyncPlan( - // remoteRsp.Contents, - // local, - // localHistory, - // this.db, - // this.settings.vaultRandomID, - // client.serviceType, - // this.settings.password - // ); - // log.info(syncPlan.mixedStates); // for debugging - // await insertSyncPlanRecordByVault( - // this.db, - // syncPlan, - // this.settings.vaultRandomID - // ); + getNotice("5/7 Starting to generate sync plan."); + this.syncStatus = "generating_plan"; + const syncPlan = await getSyncPlan( + remoteRsp.Contents, + local, + localHistory, + this.db, + this.settings.vaultRandomID, + client.serviceType, + this.settings.password + ); + log.info(syncPlan.mixedStates); // for debugging + await insertSyncPlanRecordByVault( + this.db, + syncPlan, + this.settings.vaultRandomID + ); - // // The operations above are read only and kind of safe. - // // The operations below begins to write or delete (!!!) something. + // The operations above are read only and kind of safe. + // The operations below begins to write or delete (!!!) something. - // getNotice("6/7 Remotely Save Sync data exchanging!"); + getNotice("6/7 Remotely Save Sync data exchanging!"); - // this.syncStatus = "syncing"; - // await doActualSync( - // client, - // this.db, - // this.settings.vaultRandomID, - // this.app.vault, - // syncPlan, - // this.settings.password, - // (i: number, totalCount: number, pathName: string, decision: string) => - // self.setCurrSyncMsg(i, totalCount, pathName, decision) - // ); + this.syncStatus = "syncing"; + await doActualSync( + client, + this.db, + this.settings.vaultRandomID, + this.app.vault, + syncPlan, + this.settings.password, + (i: number, totalCount: number, pathName: string, decision: string) => + self.setCurrSyncMsg(i, totalCount, pathName, decision) + ); getNotice("7/7 Remotely Save finish!"); this.currSyncMsg = "";