Skip to content

Commit b54c5f2

Browse files
committed
fix(sync): preserve platform newlines
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 0434d9c commit b54c5f2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/basic_memory/file_utils.py

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

116116
try:
117-
# Trigger: Basic Memory writes markdown and metadata from normalized Python strings.
118-
# Why: Windows text mode would translate "\n" into "\r\n", which makes the
119-
# persisted bytes diverge from the in-memory content we index and hash.
120-
# Outcome: force LF on every platform so file bytes, checksums, and move detection
121-
# stay deterministic across local and CI environments.
122-
async with aiofiles.open(temp_path, mode="w", encoding="utf-8", newline="\n") as f:
117+
# Use aiofiles for non-blocking write
118+
async with aiofiles.open(temp_path, mode="w", encoding="utf-8") as f:
123119
await f.write(content)
124120

125121
# Atomic rename (this is fast, doesn't need async)
@@ -172,7 +168,7 @@ async def format_markdown_builtin(path: Path) -> Optional[str]:
172168

173169
# Only write if content changed
174170
if formatted_content != content:
175-
async with aiofiles.open(path, mode="w", encoding="utf-8", newline="\n") as f:
171+
async with aiofiles.open(path, mode="w", encoding="utf-8") as f:
176172
await f.write(formatted_content)
177173

178174
logger.debug(

0 commit comments

Comments
 (0)