mirror of
https://github.com/remotely-save/remotely-save.git
synced 2024-06-07 21:10:45 +00:00
optimize sync plan export
This commit is contained in:
parent
3d7c4d2a4a
commit
807eec928e
@ -252,6 +252,8 @@ export interface MixedEntity {
|
|||||||
decision?: DecisionTypeForMixedEntity;
|
decision?: DecisionTypeForMixedEntity;
|
||||||
conflictAction?: ConflictActionType;
|
conflictAction?: ConflictActionType;
|
||||||
|
|
||||||
|
change?: boolean;
|
||||||
|
|
||||||
sideNotes?: any;
|
sideNotes?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,30 @@ import {
|
|||||||
} from "./localdb";
|
} from "./localdb";
|
||||||
import type { InternalDBs } from "./localdb";
|
import type { InternalDBs } from "./localdb";
|
||||||
import { mkdirpInVault } from "./misc";
|
import { mkdirpInVault } from "./misc";
|
||||||
|
import type { SyncPlanType } from "./sync";
|
||||||
|
|
||||||
|
const getSubsetOfSyncPlan = (x: string, onlyChange: boolean) => {
|
||||||
|
if (!onlyChange) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
const y: SyncPlanType = JSON.parse(x);
|
||||||
|
const z: SyncPlanType = Object.fromEntries(
|
||||||
|
Object.entries(y).filter(([key, val]) => {
|
||||||
|
if (key === "/$@meta") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return val.change === undefined || val.change === true;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return JSON.stringify(z, null, 2);
|
||||||
|
};
|
||||||
|
|
||||||
export const exportVaultSyncPlansToFiles = async (
|
export const exportVaultSyncPlansToFiles = async (
|
||||||
db: InternalDBs,
|
db: InternalDBs,
|
||||||
vault: Vault,
|
vault: Vault,
|
||||||
vaultRandomID: string,
|
vaultRandomID: string,
|
||||||
howMany: number
|
howMany: number,
|
||||||
|
onlyChange: boolean
|
||||||
) => {
|
) => {
|
||||||
console.info("exporting sync plans");
|
console.info("exporting sync plans");
|
||||||
await mkdirpInVault(DEFAULT_DEBUG_FOLDER, vault);
|
await mkdirpInVault(DEFAULT_DEBUG_FOLDER, vault);
|
||||||
@ -28,12 +46,18 @@ export const exportVaultSyncPlansToFiles = async (
|
|||||||
if (howMany <= 0) {
|
if (howMany <= 0) {
|
||||||
md =
|
md =
|
||||||
"Sync plans found:\n\n" +
|
"Sync plans found:\n\n" +
|
||||||
records.map((x) => "```json\n" + x + "\n```\n").join("\n");
|
records
|
||||||
|
.map(
|
||||||
|
(x) => "```json\n" + getSubsetOfSyncPlan(x, onlyChange) + "\n```\n"
|
||||||
|
)
|
||||||
|
.join("\n");
|
||||||
} else {
|
} else {
|
||||||
md =
|
md =
|
||||||
"Sync plans found:\n\n" +
|
"Sync plans found:\n\n" +
|
||||||
records
|
records
|
||||||
.map((x) => "```json\n" + x + "\n```\n")
|
.map(
|
||||||
|
(x) => "```json\n" + getSubsetOfSyncPlan(x, onlyChange) + "\n```\n"
|
||||||
|
)
|
||||||
.slice(0, howMany)
|
.slice(0, howMany)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
"protocol_onedrive_connect_unknown": "Do not know how to deal with the callback: {{params}}",
|
"protocol_onedrive_connect_unknown": "Do not know how to deal with the callback: {{params}}",
|
||||||
"command_startsync": "start sync",
|
"command_startsync": "start sync",
|
||||||
"command_drynrun": "start sync (dry run only)",
|
"command_drynrun": "start sync (dry run only)",
|
||||||
|
"command_exportsyncplans_1_only_change": "export sync plans (latest 1) (change part)",
|
||||||
"command_exportsyncplans_1": "export sync plans (latest 1)",
|
"command_exportsyncplans_1": "export sync plans (latest 1)",
|
||||||
"command_exportsyncplans_5": "export sync plans (latest 5)",
|
"command_exportsyncplans_5": "export sync plans (latest 5)",
|
||||||
"command_exportsyncplans_all": "export sync plans (all)",
|
"command_exportsyncplans_all": "export sync plans (all)",
|
||||||
@ -318,6 +319,7 @@
|
|||||||
"settings_viewconsolelog_desc": "On desktop, please press \"ctrl+shift+i\" or \"cmd+shift+i\" to view the log. On mobile, please install the third-party plugin <a href='https://obsidian.md/plugins?search=Logstravaganza'>Logstravaganza</a> to export the console log to a note.",
|
"settings_viewconsolelog_desc": "On desktop, please press \"ctrl+shift+i\" or \"cmd+shift+i\" to view the log. On mobile, please install the third-party plugin <a href='https://obsidian.md/plugins?search=Logstravaganza'>Logstravaganza</a> to export the console log to a note.",
|
||||||
"settings_syncplans": "Export Sync Plans",
|
"settings_syncplans": "Export Sync Plans",
|
||||||
"settings_syncplans_desc": "Sync plans are created every time after you trigger sync and before the actual sync. Useful to know what would actually happen in those sync. Click the button to export sync plans.",
|
"settings_syncplans_desc": "Sync plans are created every time after you trigger sync and before the actual sync. Useful to know what would actually happen in those sync. Click the button to export sync plans.",
|
||||||
|
"settings_syncplans_button_1_only_change": "Export latest 1 (change part)",
|
||||||
"settings_syncplans_button_1": "Export latest 1",
|
"settings_syncplans_button_1": "Export latest 1",
|
||||||
"settings_syncplans_button_5": "Export latest 5",
|
"settings_syncplans_button_5": "Export latest 5",
|
||||||
"settings_syncplans_button_all": "Export All",
|
"settings_syncplans_button_all": "Export All",
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
"command_startsync": "开始同步(start sync)",
|
"command_startsync": "开始同步(start sync)",
|
||||||
"command_drynrun": "开始同步(空跑模式)(start sync (dry run only))",
|
"command_drynrun": "开始同步(空跑模式)(start sync (dry run only))",
|
||||||
"command_exportsyncplans_json": "导出同步计划为 json 格式(export sync plans in json format)",
|
"command_exportsyncplans_json": "导出同步计划为 json 格式(export sync plans in json format)",
|
||||||
|
"command_exportsyncplans_1_only_change": "导出同步计划(最近 1 次)(仅修改部分)(export sync plans (latest 1) (change part))",
|
||||||
"command_exportsyncplans_1": "导出同步计划(最近 1 次)(export sync plans (latest 1))",
|
"command_exportsyncplans_1": "导出同步计划(最近 1 次)(export sync plans (latest 1))",
|
||||||
"command_exportsyncplans_5": "导出同步计划(最近 5 次)(export sync plans (latest 5))",
|
"command_exportsyncplans_5": "导出同步计划(最近 5 次)(export sync plans (latest 5))",
|
||||||
"command_exportsyncplans_all": "导出同步计划(所有)(export sync plans (all))",
|
"command_exportsyncplans_all": "导出同步计划(所有)(export sync plans (all))",
|
||||||
@ -317,6 +318,7 @@
|
|||||||
"settings_viewconsolelog_desc": "电脑上,输入“ctrl+shift+i”或“cmd+shift+i”来查看终端输出。手机上,安装第三方插件 <a href='https://obsidian.md/plugins?search=Logstravaganza'>Logstravaganza</a> 来导出终端输出到一篇笔记上。",
|
"settings_viewconsolelog_desc": "电脑上,输入“ctrl+shift+i”或“cmd+shift+i”来查看终端输出。手机上,安装第三方插件 <a href='https://obsidian.md/plugins?search=Logstravaganza'>Logstravaganza</a> 来导出终端输出到一篇笔记上。",
|
||||||
"settings_syncplans": "导出同步计划",
|
"settings_syncplans": "导出同步计划",
|
||||||
"settings_syncplans_desc": "每次您启动同步,并在实际上传下载前,插件会生成同步计划。它可以使您知道每次同步发生了什么。点击按钮可以导出同步计划。",
|
"settings_syncplans_desc": "每次您启动同步,并在实际上传下载前,插件会生成同步计划。它可以使您知道每次同步发生了什么。点击按钮可以导出同步计划。",
|
||||||
|
"settings_syncplans_button_1_only_change": "导出最近 1 次(仅修改部分)",
|
||||||
"settings_syncplans_button_1": "导出最近 1 次",
|
"settings_syncplans_button_1": "导出最近 1 次",
|
||||||
"settings_syncplans_button_5": "导出最近 5 次",
|
"settings_syncplans_button_5": "导出最近 5 次",
|
||||||
"settings_syncplans_button_all": "导出所有",
|
"settings_syncplans_button_all": "导出所有",
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
"protocol_onedrive_connect_unknown": "不知道如何處理此 callback:{{params}}",
|
"protocol_onedrive_connect_unknown": "不知道如何處理此 callback:{{params}}",
|
||||||
"command_startsync": "開始同步(start sync)",
|
"command_startsync": "開始同步(start sync)",
|
||||||
"command_drynrun": "開始同步(空跑模式)(start sync (dry run only))",
|
"command_drynrun": "開始同步(空跑模式)(start sync (dry run only))",
|
||||||
|
"command_exportsyncplans_1_only_change": "匯出同步計劃(最近 1 次)(僅修改部分)(export sync plans (latest 1) (change part))",
|
||||||
"command_exportsyncplans_1": "匯出同步計劃(最近 1 次)(export sync plans (latest 1))",
|
"command_exportsyncplans_1": "匯出同步計劃(最近 1 次)(export sync plans (latest 1))",
|
||||||
"command_exportsyncplans_5": "匯出同步計劃(最近 5 次)(export sync plans (latest 5))",
|
"command_exportsyncplans_5": "匯出同步計劃(最近 5 次)(export sync plans (latest 5))",
|
||||||
"command_exportsyncplans_all": "匯出同步計劃(所有)(export sync plans (all))",
|
"command_exportsyncplans_all": "匯出同步計劃(所有)(export sync plans (all))",
|
||||||
@ -316,6 +317,7 @@
|
|||||||
"settings_viewconsolelog_desc": "電腦上,輸入“ctrl+shift+i”或“cmd+shift+i”來檢視終端輸出。手機上,安裝第三方外掛 <a href='https://obsidian.md/plugins?search=Logstravaganza'>Logstravaganza</a> 來匯出終端輸出到一篇筆記上。",
|
"settings_viewconsolelog_desc": "電腦上,輸入“ctrl+shift+i”或“cmd+shift+i”來檢視終端輸出。手機上,安裝第三方外掛 <a href='https://obsidian.md/plugins?search=Logstravaganza'>Logstravaganza</a> 來匯出終端輸出到一篇筆記上。",
|
||||||
"settings_syncplans": "匯出同步計劃",
|
"settings_syncplans": "匯出同步計劃",
|
||||||
"settings_syncplans_desc": "每次您啟動同步,並在實際上傳下載前,外掛會生成同步計劃。它可以使您知道每次同步發生了什麼。點選按鈕可以匯出同步計劃。",
|
"settings_syncplans_desc": "每次您啟動同步,並在實際上傳下載前,外掛會生成同步計劃。它可以使您知道每次同步發生了什麼。點選按鈕可以匯出同步計劃。",
|
||||||
|
"settings_syncplans_button_1_only_change": "匯出最近 1 次(僅修改部分)",
|
||||||
"settings_syncplans_button_1": "匯出最近 1 次",
|
"settings_syncplans_button_1": "匯出最近 1 次",
|
||||||
"settings_syncplans_button_5": "匯出最近 5 次",
|
"settings_syncplans_button_5": "匯出最近 5 次",
|
||||||
"settings_syncplans_button_all": "匯出所有",
|
"settings_syncplans_button_all": "匯出所有",
|
||||||
|
25
src/main.ts
25
src/main.ts
@ -745,6 +745,22 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: "export-sync-plans-1-only-change",
|
||||||
|
name: t("command_exportsyncplans_1_only_change"),
|
||||||
|
icon: iconNameLogs,
|
||||||
|
callback: async () => {
|
||||||
|
await exportVaultSyncPlansToFiles(
|
||||||
|
this.db,
|
||||||
|
this.app.vault,
|
||||||
|
this.vaultRandomID,
|
||||||
|
1,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
new Notice(t("settings_syncplans_notice"));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: "export-sync-plans-1",
|
id: "export-sync-plans-1",
|
||||||
name: t("command_exportsyncplans_1"),
|
name: t("command_exportsyncplans_1"),
|
||||||
@ -754,7 +770,8 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
this.db,
|
this.db,
|
||||||
this.app.vault,
|
this.app.vault,
|
||||||
this.vaultRandomID,
|
this.vaultRandomID,
|
||||||
1
|
1,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
new Notice(t("settings_syncplans_notice"));
|
new Notice(t("settings_syncplans_notice"));
|
||||||
},
|
},
|
||||||
@ -769,7 +786,8 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
this.db,
|
this.db,
|
||||||
this.app.vault,
|
this.app.vault,
|
||||||
this.vaultRandomID,
|
this.vaultRandomID,
|
||||||
5
|
5,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
new Notice(t("settings_syncplans_notice"));
|
new Notice(t("settings_syncplans_notice"));
|
||||||
},
|
},
|
||||||
@ -784,7 +802,8 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
this.db,
|
this.db,
|
||||||
this.app.vault,
|
this.app.vault,
|
||||||
this.vaultRandomID,
|
this.vaultRandomID,
|
||||||
-1
|
-1,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
new Notice(t("settings_syncplans_notice"));
|
new Notice(t("settings_syncplans_notice"));
|
||||||
},
|
},
|
||||||
|
@ -2416,6 +2416,19 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
new Setting(debugDiv)
|
new Setting(debugDiv)
|
||||||
.setName(t("settings_syncplans"))
|
.setName(t("settings_syncplans"))
|
||||||
.setDesc(t("settings_syncplans_desc"))
|
.setDesc(t("settings_syncplans_desc"))
|
||||||
|
.addButton(async (button) => {
|
||||||
|
button.setButtonText(t("settings_syncplans_button_1_only_change"));
|
||||||
|
button.onClick(async () => {
|
||||||
|
await exportVaultSyncPlansToFiles(
|
||||||
|
this.plugin.db,
|
||||||
|
this.app.vault,
|
||||||
|
this.plugin.vaultRandomID,
|
||||||
|
1,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
new Notice(t("settings_syncplans_notice"));
|
||||||
|
});
|
||||||
|
})
|
||||||
.addButton(async (button) => {
|
.addButton(async (button) => {
|
||||||
button.setButtonText(t("settings_syncplans_button_1"));
|
button.setButtonText(t("settings_syncplans_button_1"));
|
||||||
button.onClick(async () => {
|
button.onClick(async () => {
|
||||||
@ -2423,7 +2436,8 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.db,
|
this.plugin.db,
|
||||||
this.app.vault,
|
this.app.vault,
|
||||||
this.plugin.vaultRandomID,
|
this.plugin.vaultRandomID,
|
||||||
1
|
1,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
new Notice(t("settings_syncplans_notice"));
|
new Notice(t("settings_syncplans_notice"));
|
||||||
});
|
});
|
||||||
@ -2435,7 +2449,8 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.db,
|
this.plugin.db,
|
||||||
this.app.vault,
|
this.app.vault,
|
||||||
this.plugin.vaultRandomID,
|
this.plugin.vaultRandomID,
|
||||||
5
|
5,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
new Notice(t("settings_syncplans_notice"));
|
new Notice(t("settings_syncplans_notice"));
|
||||||
});
|
});
|
||||||
@ -2447,7 +2462,8 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.db,
|
this.plugin.db,
|
||||||
this.app.vault,
|
this.app.vault,
|
||||||
this.plugin.vaultRandomID,
|
this.plugin.vaultRandomID,
|
||||||
-1
|
-1,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
new Notice(t("settings_syncplans_notice"));
|
new Notice(t("settings_syncplans_notice"));
|
||||||
});
|
});
|
||||||
|
51
src/sync.ts
51
src/sync.ts
@ -326,69 +326,83 @@ const getSyncPlanInplace = async (
|
|||||||
if (local !== undefined && remote !== undefined) {
|
if (local !== undefined && remote !== undefined) {
|
||||||
mixedEntry.decisionBranch = 101;
|
mixedEntry.decisionBranch = 101;
|
||||||
mixedEntry.decision = "folder_existed_both_then_do_nothing";
|
mixedEntry.decision = "folder_existed_both_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
} else if (local !== undefined && remote === undefined) {
|
} else if (local !== undefined && remote === undefined) {
|
||||||
if (syncDirection === "incremental_pull_only") {
|
if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 107;
|
mixedEntry.decisionBranch = 107;
|
||||||
mixedEntry.decision = "folder_to_skip";
|
mixedEntry.decision = "folder_to_skip";
|
||||||
|
mixedEntry.change = false;
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 102;
|
mixedEntry.decisionBranch = 102;
|
||||||
mixedEntry.decision =
|
mixedEntry.decision =
|
||||||
"folder_existed_local_then_also_create_remote";
|
"folder_existed_local_then_also_create_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
}
|
}
|
||||||
} else if (local === undefined && remote !== undefined) {
|
} else if (local === undefined && remote !== undefined) {
|
||||||
if (syncDirection === "incremental_push_only") {
|
if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 108;
|
mixedEntry.decisionBranch = 108;
|
||||||
mixedEntry.decision = "folder_to_skip";
|
mixedEntry.decision = "folder_to_skip";
|
||||||
|
mixedEntry.change = false;
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 103;
|
mixedEntry.decisionBranch = 103;
|
||||||
mixedEntry.decision =
|
mixedEntry.decision =
|
||||||
"folder_existed_remote_then_also_create_local";
|
"folder_existed_remote_then_also_create_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// why?? how??
|
// why?? how??
|
||||||
mixedEntry.decisionBranch = 104;
|
mixedEntry.decisionBranch = 104;
|
||||||
mixedEntry.decision = "folder_to_be_created";
|
mixedEntry.decision = "folder_to_be_created";
|
||||||
|
mixedEntry.change = true;
|
||||||
}
|
}
|
||||||
keptFolder.delete(key); // no need to save it in the Set later
|
keptFolder.delete(key); // no need to save it in the Set later
|
||||||
} else {
|
} else {
|
||||||
if (howToCleanEmptyFolder === "skip") {
|
if (howToCleanEmptyFolder === "skip") {
|
||||||
mixedEntry.decisionBranch = 105;
|
mixedEntry.decisionBranch = 105;
|
||||||
mixedEntry.decision = "folder_to_skip";
|
mixedEntry.decision = "folder_to_skip";
|
||||||
|
mixedEntry.change = false;
|
||||||
} else if (howToCleanEmptyFolder === "clean_both") {
|
} else if (howToCleanEmptyFolder === "clean_both") {
|
||||||
if (local !== undefined && remote !== undefined) {
|
if (local !== undefined && remote !== undefined) {
|
||||||
if (syncDirection === "bidirectional") {
|
if (syncDirection === "bidirectional") {
|
||||||
mixedEntry.decisionBranch = 106;
|
mixedEntry.decisionBranch = 106;
|
||||||
mixedEntry.decision = "folder_to_be_deleted_on_both";
|
mixedEntry.decision = "folder_to_be_deleted_on_both";
|
||||||
|
mixedEntry.change = true;
|
||||||
} else {
|
} else {
|
||||||
// right now it does nothing because of "incremental"
|
// right now it does nothing because of "incremental"
|
||||||
// TODO: should we delete??
|
// TODO: should we delete??
|
||||||
mixedEntry.decisionBranch = 109;
|
mixedEntry.decisionBranch = 109;
|
||||||
mixedEntry.decision = "folder_to_skip";
|
mixedEntry.decision = "folder_to_skip";
|
||||||
|
mixedEntry.change = false;
|
||||||
}
|
}
|
||||||
} else if (local !== undefined && remote === undefined) {
|
} else if (local !== undefined && remote === undefined) {
|
||||||
if (syncDirection === "bidirectional") {
|
if (syncDirection === "bidirectional") {
|
||||||
mixedEntry.decisionBranch = 110;
|
mixedEntry.decisionBranch = 110;
|
||||||
mixedEntry.decision = "folder_to_be_deleted_on_local";
|
mixedEntry.decision = "folder_to_be_deleted_on_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
} else {
|
} else {
|
||||||
// right now it does nothing because of "incremental"
|
// right now it does nothing because of "incremental"
|
||||||
// TODO: should we delete??
|
// TODO: should we delete??
|
||||||
mixedEntry.decisionBranch = 111;
|
mixedEntry.decisionBranch = 111;
|
||||||
mixedEntry.decision = "folder_to_skip";
|
mixedEntry.decision = "folder_to_skip";
|
||||||
|
mixedEntry.change = false;
|
||||||
}
|
}
|
||||||
} else if (local === undefined && remote !== undefined) {
|
} else if (local === undefined && remote !== undefined) {
|
||||||
if (syncDirection === "bidirectional") {
|
if (syncDirection === "bidirectional") {
|
||||||
mixedEntry.decisionBranch = 112;
|
mixedEntry.decisionBranch = 112;
|
||||||
mixedEntry.decision = "folder_to_be_deleted_on_remote";
|
mixedEntry.decision = "folder_to_be_deleted_on_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
} else {
|
} else {
|
||||||
// right now it does nothing because of "incremental"
|
// right now it does nothing because of "incremental"
|
||||||
// TODO: should we delete??
|
// TODO: should we delete??
|
||||||
mixedEntry.decisionBranch = 113;
|
mixedEntry.decisionBranch = 113;
|
||||||
mixedEntry.decision = "folder_to_skip";
|
mixedEntry.decision = "folder_to_skip";
|
||||||
|
mixedEntry.change = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no folder to delete, do nothing
|
// no folder to delete, do nothing
|
||||||
mixedEntry.decisionBranch = 114;
|
mixedEntry.decisionBranch = 114;
|
||||||
mixedEntry.decision = "folder_to_skip";
|
mixedEntry.decision = "folder_to_skip";
|
||||||
|
mixedEntry.change = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw Error(
|
throw Error(
|
||||||
@ -403,6 +417,7 @@ const getSyncPlanInplace = async (
|
|||||||
// both deleted, only in history
|
// both deleted, only in history
|
||||||
mixedEntry.decisionBranch = 1;
|
mixedEntry.decisionBranch = 1;
|
||||||
mixedEntry.decision = "only_history";
|
mixedEntry.decision = "only_history";
|
||||||
|
mixedEntry.change = false;
|
||||||
} else if (local !== undefined && remote !== undefined) {
|
} else if (local !== undefined && remote !== undefined) {
|
||||||
if (
|
if (
|
||||||
(local.mtimeCli === remote.mtimeCli ||
|
(local.mtimeCli === remote.mtimeCli ||
|
||||||
@ -412,6 +427,7 @@ const getSyncPlanInplace = async (
|
|||||||
// completely equal / identical
|
// completely equal / identical
|
||||||
mixedEntry.decisionBranch = 2;
|
mixedEntry.decisionBranch = 2;
|
||||||
mixedEntry.decision = "equal";
|
mixedEntry.decision = "equal";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
// Both exists, but modified or conflict
|
// Both exists, but modified or conflict
|
||||||
@ -434,10 +450,12 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_push_only") {
|
if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 26;
|
mixedEntry.decisionBranch = 26;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_local";
|
mixedEntry.decision = "conflict_modified_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 9;
|
mixedEntry.decisionBranch = 9;
|
||||||
mixedEntry.decision = "remote_is_modified_then_pull";
|
mixedEntry.decision = "remote_is_modified_then_pull";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -456,10 +474,12 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_pull_only") {
|
if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 27;
|
mixedEntry.decisionBranch = 27;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 10;
|
mixedEntry.decisionBranch = 10;
|
||||||
mixedEntry.decision = "local_is_modified_then_push";
|
mixedEntry.decision = "local_is_modified_then_push";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -481,34 +501,41 @@ const getSyncPlanInplace = async (
|
|||||||
) {
|
) {
|
||||||
mixedEntry.decisionBranch = 11;
|
mixedEntry.decisionBranch = 11;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_local";
|
mixedEntry.decision = "conflict_created_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 12;
|
mixedEntry.decisionBranch = 12;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_remote";
|
mixedEntry.decision = "conflict_created_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else if (conflictAction === "keep_larger") {
|
} else if (conflictAction === "keep_larger") {
|
||||||
if (local.sizeEnc! >= remote.sizeEnc!) {
|
if (local.sizeEnc! >= remote.sizeEnc!) {
|
||||||
mixedEntry.decisionBranch = 13;
|
mixedEntry.decisionBranch = 13;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_local";
|
mixedEntry.decision = "conflict_created_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 14;
|
mixedEntry.decisionBranch = 14;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_remote";
|
mixedEntry.decision = "conflict_created_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 15;
|
mixedEntry.decisionBranch = 15;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_both";
|
mixedEntry.decision = "conflict_created_then_keep_both";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else if (syncDirection === "incremental_pull_only") {
|
} else if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 22;
|
mixedEntry.decisionBranch = 22;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_remote";
|
mixedEntry.decision = "conflict_created_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else if (syncDirection === "incremental_push_only") {
|
} else if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 23;
|
mixedEntry.decisionBranch = 23;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_local";
|
mixedEntry.decision = "conflict_created_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
throw Error(
|
throw Error(
|
||||||
@ -525,34 +552,41 @@ const getSyncPlanInplace = async (
|
|||||||
) {
|
) {
|
||||||
mixedEntry.decisionBranch = 16;
|
mixedEntry.decisionBranch = 16;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_local";
|
mixedEntry.decision = "conflict_modified_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 17;
|
mixedEntry.decisionBranch = 17;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else if (conflictAction === "keep_larger") {
|
} else if (conflictAction === "keep_larger") {
|
||||||
if (local.sizeEnc! >= remote.sizeEnc!) {
|
if (local.sizeEnc! >= remote.sizeEnc!) {
|
||||||
mixedEntry.decisionBranch = 18;
|
mixedEntry.decisionBranch = 18;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_local";
|
mixedEntry.decision = "conflict_modified_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 19;
|
mixedEntry.decisionBranch = 19;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 20;
|
mixedEntry.decisionBranch = 20;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_both";
|
mixedEntry.decision = "conflict_modified_then_keep_both";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else if (syncDirection === "incremental_pull_only") {
|
} else if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 24;
|
mixedEntry.decisionBranch = 24;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
mixedEntry.decision = "conflict_modified_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else if (syncDirection === "incremental_push_only") {
|
} else if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 25;
|
mixedEntry.decisionBranch = 25;
|
||||||
mixedEntry.decision = "conflict_modified_then_keep_local";
|
mixedEntry.decision = "conflict_modified_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
throw Error(
|
throw Error(
|
||||||
@ -566,6 +600,7 @@ const getSyncPlanInplace = async (
|
|||||||
// The result should be equal!!!
|
// The result should be equal!!!
|
||||||
mixedEntry.decisionBranch = 21;
|
mixedEntry.decisionBranch = 21;
|
||||||
mixedEntry.decision = "equal";
|
mixedEntry.decision = "equal";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -580,15 +615,18 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_push_only") {
|
if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 28;
|
mixedEntry.decisionBranch = 28;
|
||||||
mixedEntry.decision = "conflict_created_then_do_nothing";
|
mixedEntry.decision = "conflict_created_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 3;
|
mixedEntry.decisionBranch = 3;
|
||||||
mixedEntry.decision = "remote_is_created_then_pull";
|
mixedEntry.decision = "remote_is_created_then_pull";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 36;
|
mixedEntry.decisionBranch = 36;
|
||||||
mixedEntry.decision = "remote_is_created_too_large_then_do_nothing";
|
mixedEntry.decision = "remote_is_created_too_large_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
@ -600,14 +638,17 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_push_only") {
|
if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 29;
|
mixedEntry.decisionBranch = 29;
|
||||||
mixedEntry.decision = "conflict_created_then_do_nothing";
|
mixedEntry.decision = "conflict_created_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else if (syncDirection === "incremental_pull_only") {
|
} else if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 35;
|
mixedEntry.decisionBranch = 35;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_remote";
|
mixedEntry.decision = "conflict_created_then_keep_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 4;
|
mixedEntry.decisionBranch = 4;
|
||||||
mixedEntry.decision = "local_is_deleted_thus_also_delete_remote";
|
mixedEntry.decision = "local_is_deleted_thus_also_delete_remote";
|
||||||
|
mixedEntry.change = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if B is in the previous list and MODIFIED, B has been deleted by A but modified by B
|
// if B is in the previous list and MODIFIED, B has been deleted by A but modified by B
|
||||||
@ -618,10 +659,12 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_push_only") {
|
if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 30;
|
mixedEntry.decisionBranch = 30;
|
||||||
mixedEntry.decision = "conflict_created_then_do_nothing";
|
mixedEntry.decision = "conflict_created_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 5;
|
mixedEntry.decisionBranch = 5;
|
||||||
mixedEntry.decision = "remote_is_modified_then_pull";
|
mixedEntry.decision = "remote_is_modified_then_pull";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -641,15 +684,18 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_pull_only") {
|
if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 31;
|
mixedEntry.decisionBranch = 31;
|
||||||
mixedEntry.decision = "conflict_created_then_do_nothing";
|
mixedEntry.decision = "conflict_created_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 6;
|
mixedEntry.decisionBranch = 6;
|
||||||
mixedEntry.decision = "local_is_created_then_push";
|
mixedEntry.decision = "local_is_created_then_push";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 37;
|
mixedEntry.decisionBranch = 37;
|
||||||
mixedEntry.decision = "local_is_created_too_large_then_do_nothing";
|
mixedEntry.decision = "local_is_created_too_large_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
@ -661,12 +707,15 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_push_only") {
|
if (syncDirection === "incremental_push_only") {
|
||||||
mixedEntry.decisionBranch = 32;
|
mixedEntry.decisionBranch = 32;
|
||||||
mixedEntry.decision = "conflict_created_then_keep_local";
|
mixedEntry.decision = "conflict_created_then_keep_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
} else if (syncDirection === "incremental_pull_only") {
|
} else if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 33;
|
mixedEntry.decisionBranch = 33;
|
||||||
mixedEntry.decision = "conflict_created_then_do_nothing";
|
mixedEntry.decision = "conflict_created_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 7;
|
mixedEntry.decisionBranch = 7;
|
||||||
mixedEntry.decision = "remote_is_deleted_thus_also_delete_local";
|
mixedEntry.decision = "remote_is_deleted_thus_also_delete_local";
|
||||||
|
mixedEntry.change = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if A is in the previous list and MODIFIED, A has been deleted by B but modified by A
|
// if A is in the previous list and MODIFIED, A has been deleted by B but modified by A
|
||||||
@ -674,10 +723,12 @@ const getSyncPlanInplace = async (
|
|||||||
if (syncDirection === "incremental_pull_only") {
|
if (syncDirection === "incremental_pull_only") {
|
||||||
mixedEntry.decisionBranch = 34;
|
mixedEntry.decisionBranch = 34;
|
||||||
mixedEntry.decision = "conflict_created_then_do_nothing";
|
mixedEntry.decision = "conflict_created_then_do_nothing";
|
||||||
|
mixedEntry.change = false;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
} else {
|
} else {
|
||||||
mixedEntry.decisionBranch = 8;
|
mixedEntry.decisionBranch = 8;
|
||||||
mixedEntry.decision = "local_is_modified_then_push";
|
mixedEntry.decision = "local_is_modified_then_push";
|
||||||
|
mixedEntry.change = true;
|
||||||
keptFolder.add(getParentFolder(key));
|
keptFolder.add(getParentFolder(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user