Skip to content

Commit 893e3eb

Browse files
committed
fix(core): preserve file sizes in unindexed status
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent a6874c4 commit 893e3eb

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/basic_memory/index/local_project.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,15 @@ async def list_observed_index_files(self) -> tuple[RuntimeObservedIndexFile, ...
317317
if self.indexed_stat_source is not None
318318
else {}
319319
)
320-
# With a confirmed empty index, every discovered path is new. Hashes
321-
# cannot identify changes or moves yet; the batch reader computes them
322-
# when indexing content. Status can therefore count files without reads.
323-
if self.indexed_stat_source is not None and not indexed_stats:
324-
return tuple(RuntimeObservedIndexFile(path=path) for path in file_paths)
325-
326320
observed_files: list[RuntimeObservedIndexFile] = []
327321
for file_path in file_paths:
328322
try:
329323
metadata = await self.file_service.get_file_metadata(file_path)
330324
checksum = self._reuse_indexed_checksum(file_path, metadata, indexed_stats)
331-
if checksum is None:
325+
# A confirmed empty index has no changed or moved files to
326+
# compare. Keep stat metadata, but let the batch reader hash
327+
# new content when indexing rather than during status.
328+
if checksum is None and (self.indexed_stat_source is None or indexed_stats):
332329
checksum = await self.file_service.compute_checksum(file_path)
333330
except (OSError, FileError, FileOperationError) as exc:
334331
# Trigger: a path the walk just listed fails stat/checksum

test-int/cli/test_status_wait_integration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ async def unexpected_checksum(self: FileService, path: str) -> str:
6666
assert data["readiness"]["indexed_entities"] == 0
6767
files = next(stage for stage in data["readiness"]["stages"] if stage["name"] == "files")
6868
assert files["pending"] == files["total"] == 2
69+
assert {item["path"]: item["size"] for item in data["observed_files"]} == {
70+
"notes/new.md": len(b"# New\n"),
71+
"asset.txt": len(b"unindexed asset"),
72+
}

0 commit comments

Comments
 (0)