more accurate stages of sync
This commit is contained in:
parent
659deb9830
commit
bcca2b4446
21
src/main.ts
21
src/main.ts
@ -64,20 +64,28 @@ export default class SaveRemotePlugin extends Plugin {
|
|||||||
|
|
||||||
this.addRibbonIcon("switch", "Save Remote", async () => {
|
this.addRibbonIcon("switch", "Save Remote", async () => {
|
||||||
if (this.syncStatus !== "idle") {
|
if (this.syncStatus !== "idle") {
|
||||||
new Notice("Save Remote already running!");
|
new Notice(`Save Remote already running in stage ${this.syncStatus}!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new Notice("Save Remote Sync Preparing");
|
try {
|
||||||
|
new Notice("1/6 Save Remote Sync Preparing");
|
||||||
this.syncStatus = "preparing";
|
this.syncStatus = "preparing";
|
||||||
|
|
||||||
|
new Notice("2/6 Starting to fetch remote meta data.");
|
||||||
|
this.syncStatus = "getting_remote_meta";
|
||||||
const s3Client = getS3Client(this.settings.s3);
|
const s3Client = getS3Client(this.settings.s3);
|
||||||
const remoteRsp = await listFromRemote(s3Client, this.settings.s3);
|
const remoteRsp = await listFromRemote(s3Client, this.settings.s3);
|
||||||
|
|
||||||
|
new Notice("3/6 Starting to fetch local meta data.");
|
||||||
|
this.syncStatus = "getting_local_meta";
|
||||||
const local = this.app.vault.getAllLoadedFiles();
|
const local = this.app.vault.getAllLoadedFiles();
|
||||||
const localHistory = await loadDeleteRenameHistoryTable(this.db);
|
const localHistory = await loadDeleteRenameHistoryTable(this.db);
|
||||||
// console.log(remoteRsp);
|
// console.log(remoteRsp);
|
||||||
// console.log(local);
|
// console.log(local);
|
||||||
// console.log(localHistory);
|
// console.log(localHistory);
|
||||||
|
|
||||||
|
new Notice("4/6 Starting to generate sync plan.");
|
||||||
const mixedStates = await ensembleMixedStates(
|
const mixedStates = await ensembleMixedStates(
|
||||||
remoteRsp.Contents,
|
remoteRsp.Contents,
|
||||||
local,
|
local,
|
||||||
@ -95,8 +103,9 @@ export default class SaveRemotePlugin extends Plugin {
|
|||||||
// The operations above are read only and kind of safe.
|
// The operations above are read only and kind of safe.
|
||||||
// The operations below begins to write or delete (!!!) something.
|
// The operations below begins to write or delete (!!!) something.
|
||||||
|
|
||||||
new Notice("Save Remote Sync data exchanging!");
|
new Notice("5/6 Save Remote Sync data exchanging!");
|
||||||
|
|
||||||
|
this.syncStatus = "syncing";
|
||||||
await doActualSync(
|
await doActualSync(
|
||||||
s3Client,
|
s3Client,
|
||||||
this.settings.s3,
|
this.settings.s3,
|
||||||
@ -106,8 +115,12 @@ export default class SaveRemotePlugin extends Plugin {
|
|||||||
this.settings.password
|
this.settings.password
|
||||||
);
|
);
|
||||||
|
|
||||||
new Notice("Save Remote finish!");
|
new Notice("6/6 Save Remote finish!");
|
||||||
this.syncStatus = "idle";
|
this.syncStatus = "idle";
|
||||||
|
} catch (error) {
|
||||||
|
new Notice(`Save Remote error while ${this.syncStatus}: ${error}`);
|
||||||
|
this.syncStatus = "idle";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addSettingTab(new SaveRemoteSettingTab(this.app, this));
|
this.addSettingTab(new SaveRemoteSettingTab(this.app, this));
|
||||||
|
|||||||
@ -31,7 +31,14 @@ type DecisionType =
|
|||||||
| "mkdirplocal"
|
| "mkdirplocal"
|
||||||
| "skip";
|
| "skip";
|
||||||
|
|
||||||
export type SyncStatusType = "idle" | "preparing" | "syncing";
|
export type SyncStatusType =
|
||||||
|
| "idle"
|
||||||
|
| "preparing"
|
||||||
|
| "getting_remote_meta"
|
||||||
|
| "getting_local_meta"
|
||||||
|
| "generating_plan"
|
||||||
|
| "syncing"
|
||||||
|
| "finish";
|
||||||
|
|
||||||
interface FileOrFolderMixedState {
|
interface FileOrFolderMixedState {
|
||||||
key: string;
|
key: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user