Skip to content

Commit 3f23b3e

Browse files
committed
docs(core): explain windows newline checksum behavior
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent b54c5f2 commit 3f23b3e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/basic_memory/file_utils.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ async def write_file_atomic(path: FilePath, content: str) -> None:
114114
temp_path = path_obj.with_suffix(".tmp")
115115

116116
try:
117-
# Use aiofiles for non-blocking write
117+
# Trigger: callers hand us normalized Python text, but the final bytes are allowed
118+
# to use the host platform's native newline convention during the write.
119+
# Why: preserving CRLF on Windows keeps local files aligned with editors like
120+
# Obsidian, while FileService now hashes the persisted file bytes instead of
121+
# the pre-write string.
122+
# Outcome: this async write stays editor-friendly across platforms without
123+
# reintroducing checksum drift in sync or move detection.
118124
async with aiofiles.open(temp_path, mode="w", encoding="utf-8") as f:
119125
await f.write(content)
120126

@@ -168,6 +174,13 @@ async def format_markdown_builtin(path: Path) -> Optional[str]:
168174

169175
# Only write if content changed
170176
if formatted_content != content:
177+
# Trigger: mdformat may rewrite markdown content, then the host platform
178+
# decides the newline bytes for the follow-up async text write.
179+
# Why: we want formatter output to preserve native newlines instead of
180+
# forcing LF, and the authoritative checksum comes from rereading the
181+
# stored file bytes later in FileService.
182+
# Outcome: formatting remains compatible with local editors on Windows while
183+
# checksum-based sync logic stays anchored to on-disk bytes.
171184
async with aiofiles.open(path, mode="w", encoding="utf-8") as f:
172185
await f.write(formatted_content)
173186

0 commit comments

Comments
 (0)