private void VerifyLooseObject(AnyObjectId id, byte[] compressed)
{
UnpackedObjectLoader uol;
try
{
uol = new UnpackedObjectLoader(compressed);
}
catch (CorruptObjectException parsingError)
{
var e = new FileNotFoundException(id.Name, parsingError);
throw e;
}
_objectDigest.Reset();
_objectDigest.Update(Constants.encodedTypeString(uol.Type));
_objectDigest.Update((byte)' ');
_objectDigest.Update(Constants.encodeASCII(uol.Size));
_objectDigest.Update(0);
_objectDigest.Update(uol.CachedBytes);
_idBuffer.FromRaw(_objectDigest.Digest(), 0);
if (!id.Equals(_idBuffer))
{
throw new TransportException("Incorrect hash for " + id.Name + "; computed " + _idBuffer.Name + " as a " +
Constants.typeString(uol.Type) + " from " + compressed.Length +
" bytes.");
}
if (_objCheck != null)
{
try
{
_objCheck.check(uol.Type, uol.CachedBytes);
}
catch (CorruptObjectException e)
{
throw new TransportException("Invalid " + Constants.typeString(uol.Type) + " " + id.Name + ": " + e.Message);
}
}
}