From 11c66d7030b54891bf02a1058a5f8e9437d5aa0e Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Fri, 28 Jun 2024 23:17:41 +0800 Subject: [PATCH] fix smart conflict for .obsidian --- pro/src/sync.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pro/src/sync.ts b/pro/src/sync.ts index 7382f70..d08d90a 100644 --- a/pro/src/sync.ts +++ b/pro/src/sync.ts @@ -296,7 +296,8 @@ const getSyncPlanInplace = async ( syncDirection: SyncDirectionType, profiler: Profiler | undefined, settings: RemotelySavePluginSettings, - triggerSource: SyncTriggerSourceType + triggerSource: SyncTriggerSourceType, + configDir: string ) => { profiler?.addIndent(); profiler?.insert("getSyncPlanInplace: enter"); @@ -582,7 +583,11 @@ const getSyncPlanInplace = async ( if (prevSync === undefined) { // Didn't exist means both are new if (syncDirection === "bidirectional") { - if (conflictAction === "keep_newer") { + if ( + conflictAction === "keep_newer" || + (conflictAction === "smart_conflict" && + key.startsWith(`${configDir}/`)) + ) { if ( (local.mtimeCli ?? local.mtimeSvr ?? 0) >= (remote.mtimeCli ?? remote.mtimeSvr ?? 0) @@ -640,7 +645,11 @@ const getSyncPlanInplace = async ( } else { // Both exist but don't compare means both are modified if (syncDirection === "bidirectional") { - if (conflictAction === "keep_newer") { + if ( + conflictAction === "keep_newer" || + (conflictAction === "smart_conflict" && + key.startsWith(`${configDir}/`)) + ) { if ( (local.mtimeCli ?? local.mtimeSvr ?? 0) >= (remote.mtimeCli ?? remote.mtimeSvr ?? 0) @@ -1712,7 +1721,8 @@ export async function syncer( settings.syncDirection ?? "bidirectional", profiler, settings, - triggerSource + triggerSource, + configDir ); console.debug(`mixedEntityMappings:`); console.debug(mixedEntityMappings); // for debugging