27 lines
634 B
Rust
27 lines
634 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{
|
|
bare::GitBare,
|
|
cmd::oid::ObjectId,
|
|
errors::{GitError, GitResult},
|
|
};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BlobSizeParams {
|
|
pub id: ObjectId,
|
|
pub path: String,
|
|
}
|
|
|
|
impl GitBare {
|
|
pub fn blob_size(&self, params: &BlobSizeParams) -> GitResult<u64> {
|
|
let repo = self.gix_repo()?;
|
|
let gix_id: gix::hash::ObjectId = (¶ms.id).try_into()?;
|
|
|
|
let header = repo.find_header(gix_id).map_err(|_| {
|
|
GitError::ObjectNotFound(params.id.as_str().to_string())
|
|
})?;
|
|
|
|
Ok(header.size() as u64)
|
|
}
|
|
}
|