Skip to content

feat(grpc): return real blob sizes in ListFiles responses #125

@juliuskrah

Description

@juliuskrah

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions