mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-26 12:34:22 +01:00
Merge 'Enable checksums only if its opted in via feature flag' from Avinash Sajjanshetty
Reviewed-by: Nikita Sivukhin (@sivukhin) Reviewed-by: bit-aloo (@Shourya742) Closes #3523
This commit is contained in:
@@ -132,6 +132,8 @@ pub enum CompletionError {
|
||||
expected: u64,
|
||||
actual: u64,
|
||||
},
|
||||
#[error("tursodb not compiled with checksum feature")]
|
||||
ChecksumNotEnabled,
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
||||
@@ -15,7 +15,11 @@ impl ChecksumContext {
|
||||
|
||||
#[cfg(not(feature = "checksum"))]
|
||||
pub fn add_checksum_to_page(&self, _page: &mut [u8], _page_id: usize) -> Result<()> {
|
||||
Ok(())
|
||||
use crate::LimboError;
|
||||
Err(LimboError::InternalError(
|
||||
"tursodb must be recompiled with checksum feature in order to use checksums"
|
||||
.to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "checksum"))]
|
||||
@@ -24,7 +28,7 @@ impl ChecksumContext {
|
||||
_page: &mut [u8],
|
||||
_page_id: usize,
|
||||
) -> std::result::Result<(), CompletionError> {
|
||||
Ok(())
|
||||
Err(CompletionError::ChecksumNotEnabled)
|
||||
}
|
||||
|
||||
#[cfg(feature = "checksum")]
|
||||
|
||||
@@ -48,8 +48,12 @@ impl IOContext {
|
||||
|
||||
impl Default for IOContext {
|
||||
fn default() -> Self {
|
||||
#[cfg(feature = "checksum")]
|
||||
let encryption_or_checksum = EncryptionOrChecksum::Checksum(ChecksumContext::default());
|
||||
#[cfg(not(feature = "checksum"))]
|
||||
let encryption_or_checksum = EncryptionOrChecksum::None;
|
||||
Self {
|
||||
encryption_or_checksum: EncryptionOrChecksum::Checksum(ChecksumContext::default()),
|
||||
encryption_or_checksum,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user