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 () => {
|
||||
if (this.syncStatus !== "idle") {
|
||||
new Notice("Save Remote already running!");
|
||||
new Notice(`Save Remote already running in stage ${this.syncStatus}!`);
|
||||
return;
|
||||
}
|
||||
|
||||
new Notice("Save Remote Sync Preparing");
|
||||
try {
|
||||
new Notice("1/6 Save Remote Sync 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 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 localHistory = await loadDeleteRenameHistoryTable(this.db);
|
||||
// console.log(remoteRsp);
|
||||
// console.log(local);
|
||||
// console.log(localHistory);
|
||||
|
||||
new Notice("4/6 Starting to generate sync plan.");
|
||||
const mixedStates = await ensembleMixedStates(
|
||||
remoteRsp.Contents,
|
||||
local,
|
||||
@ -95,8 +103,9 @@ export default class SaveRemotePlugin extends Plugin {
|
||||
// The operations above are read only and kind of safe.
|
||||
// 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(
|
||||
s3Client,
|
||||
this.settings.s3,
|
||||
@ -106,8 +115,12 @@ export default class SaveRemotePlugin extends Plugin {
|
||||
this.settings.password
|
||||
);
|
||||
|
||||
new Notice("Save Remote finish!");
|
||||
new Notice("6/6 Save Remote finish!");
|
||||
this.syncStatus = "idle";
|
||||
} catch (error) {
|
||||
new Notice(`Save Remote error while ${this.syncStatus}: ${error}`);
|
||||
this.syncStatus = "idle";
|
||||
}
|
||||
});
|
||||
|
||||
this.addSettingTab(new SaveRemoteSettingTab(this.app, this));
|
||||
|
||||
@ -31,7 +31,14 @@ type DecisionType =
|
||||
| "mkdirplocal"
|
||||
| "skip";
|
||||
|
||||
export type SyncStatusType = "idle" | "preparing" | "syncing";
|
||||
export type SyncStatusType =
|
||||
| "idle"
|
||||
| "preparing"
|
||||
| "getting_remote_meta"
|
||||
| "getting_local_meta"
|
||||
| "generating_plan"
|
||||
| "syncing"
|
||||
| "finish";
|
||||
|
||||
interface FileOrFolderMixedState {
|
||||
key: string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user