Background
list_tree_files in the git-service currently hard-codes size_bytes: 0 for every FileEntry:
// gitstore-git-service/src/grpc/server.rs
files.push(FileEntry {
path: full_path,
size_bytes: 0, // placeholder
blob_sha: entry.id().to_string(),
});
This violates the proto contract field semantics and makes size-aware client logic incorrect — for example, a client choosing between unary GetFile and streaming GetFileStream based on file size cannot make that decision correctly.
Proposed fix
Resolve the blob object for each entry during the tree walk and read its size:
if let Ok(blob) = _repo.find_blob(entry.id()) {
size_bytes: blob.content().len() as u64,
}
Performance note: loading every blob during a listing is potentially expensive on large trees. Consider only populating size_bytes when the tree is shallow (e.g. the caller filters by a prefix that yields few entries), or add an include_sizes: bool field to ListFilesRequest so callers opt in.
Acceptance criteria
FileEntry.size_bytes reflects the actual byte length of the blob content
ListFiles unit test verifies the field is non-zero for known files
- No significant regression in listing latency for typical catalog sizes (~hundreds of files)
Identified during review of #122.
Background
list_tree_filesin the git-service currently hard-codessize_bytes: 0for everyFileEntry:This violates the proto contract field semantics and makes size-aware client logic incorrect — for example, a client choosing between unary
GetFileand streamingGetFileStreambased on file size cannot make that decision correctly.Proposed fix
Resolve the blob object for each entry during the tree walk and read its size:
Performance note: loading every blob during a listing is potentially expensive on large trees. Consider only populating
size_byteswhen the tree is shallow (e.g. the caller filters by a prefix that yields few entries), or add aninclude_sizes: boolfield toListFilesRequestso callers opt in.Acceptance criteria
FileEntry.size_bytesreflects the actual byte length of the blob contentListFilesunit test verifies the field is non-zero for known filesIdentified during review of #122.