mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
Fix blob size calculation
Summary: We had two separate issues in blob size, which were breaking `test-eden-server.t`: 1. The value documented as "blob size without metadata" was calculated with metadata included (because we didn't strip the metadata from the content blob). 2. If the BlobNode was clean (i.e. had both data and a hash), the size was the size of the hash, not the data. Reviewed By: StanislavGlebik Differential Revision: D7167581 fbshipit-source-id: 965778c1d053af36c760a988f0d34130052e8a1a
This commit is contained in:
parent
14031b91b6
commit
98bc1a4e81
@ -131,18 +131,16 @@ impl Entry for BlobEntry {
|
||||
.and_then({
|
||||
let ty = self.ty;
|
||||
move |bytes| {
|
||||
let blob = bytes.as_ref();
|
||||
|
||||
// Mercurial file blob can have metadata, but tree manifest can't
|
||||
let blob = if ty == Type::Tree {
|
||||
blob
|
||||
bytes
|
||||
} else {
|
||||
let (_, off) = file::File::extract_meta(blob);
|
||||
&blob[off..]
|
||||
let (_, off) = file::File::extract_meta(&bytes);
|
||||
bytes.slice_from(off)
|
||||
};
|
||||
let res = match ty {
|
||||
Type::File => Content::File(Blob::from(bytes.clone())),
|
||||
Type::Executable => Content::Executable(Blob::from(bytes.clone())),
|
||||
Type::File => Content::File(Blob::from(blob)),
|
||||
Type::Executable => Content::Executable(Blob::from(blob)),
|
||||
Type::Symlink => Content::Symlink(MPath::new(blob)?),
|
||||
Type::Tree => Content::Tree(BlobManifest::parse(blobstore, blob)?.boxed()),
|
||||
};
|
||||
|
@ -85,7 +85,7 @@ impl Blob {
|
||||
pub fn size(&self) -> Option<usize> {
|
||||
match self {
|
||||
&Blob::Dirty(ref data) => Some(data.len()),
|
||||
&Blob::Clean(_, ref data) => Some(data.as_ref().len()),
|
||||
&Blob::Clean(ref data, _) => Some(data.as_ref().len()),
|
||||
&Blob::Extern(..) | &Blob::NodeId(..) => None,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user