From 698c30313f0b2874e5a8b8d657b48e0df28b6b91 Mon Sep 17 00:00:00 2001 From: Esmodea Date: Thu, 18 Sep 2025 16:01:02 -0500 Subject: [PATCH 1/3] Updated boolean for non-deletion cases in SyncManager determineSyncActions method --- src/sync-manager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sync-manager.ts b/src/sync-manager.ts index da11a5a..f48638b 100644 --- a/src/sync-manager.ts +++ b/src/sync-manager.ts @@ -724,12 +724,12 @@ export default class SyncManager { } } - // For non-deletion cases, if SHAs differ, we just need to check if local changed. + // For non-deletion cases, if SHAs differ, we need to check if local changed and what file was modified last // Conflicts are already filtered out so we can make this decision easily - if (localSHA !== localFile.sha) { + if (localSHA !== localFile.sha && remoteFile.lastModified < localFile.lastModified) { actions.push({ type: "upload", filePath: filePath }); return; - } else { + } else if(localSHA == localFile.sha && remoteFile.lastModified > localFile.lastModified) { actions.push({ type: "download", filePath: filePath }); return; } From afbd7a337ed72e0d5a27267e5ec7dff1a94e8596 Mon Sep 17 00:00:00 2001 From: Esmodea Date: Thu, 18 Sep 2025 16:05:08 -0500 Subject: [PATCH 2/3] Fixed type errors --- mock-obsidian.ts | 2 +- src/sync-manager.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mock-obsidian.ts b/mock-obsidian.ts index 6b31c96..5b4d666 100644 --- a/mock-obsidian.ts +++ b/mock-obsidian.ts @@ -156,7 +156,7 @@ export function arrayBufferToBase64(buffer: ArrayBuffer): string { } export function base64ToArrayBuffer(base64: string): ArrayBuffer { - return Buffer.from(base64, "base64"); + return Buffer.from(base64, "base64").buffer; } // Mock Event reference diff --git a/src/sync-manager.ts b/src/sync-manager.ts index f48638b..e47fdec 100644 --- a/src/sync-manager.ts +++ b/src/sync-manager.ts @@ -261,7 +261,7 @@ export default class SyncManager { } const normalizedPath = normalizePath(targetPath); - await this.vault.adapter.writeBinary(normalizedPath, data); + await this.vault.adapter.writeBinary(normalizedPath, data.buffer); await this.logger.info("Written file", { normalizedPath, }); From 152b36f3725ad575a17409bcd97948643677a4b1 Mon Sep 17 00:00:00 2001 From: Esmodea Date: Fri, 19 Sep 2025 13:02:47 -0500 Subject: [PATCH 3/3] Removed unneeded boolean logic that caused files not to be downloaded when they should have been --- src/sync-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sync-manager.ts b/src/sync-manager.ts index e47fdec..eae673e 100644 --- a/src/sync-manager.ts +++ b/src/sync-manager.ts @@ -729,7 +729,7 @@ export default class SyncManager { if (localSHA !== localFile.sha && remoteFile.lastModified < localFile.lastModified) { actions.push({ type: "upload", filePath: filePath }); return; - } else if(localSHA == localFile.sha && remoteFile.lastModified > localFile.lastModified) { + } else if(remoteFile.lastModified > localFile.lastModified) { actions.push({ type: "download", filePath: filePath }); return; }