Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mock-obsidian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/sync-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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(remoteFile.lastModified > localFile.lastModified) {
actions.push({ type: "download", filePath: filePath });
return;
}
Expand Down