diff --git a/core/error.rs b/core/error.rs index 23ce9fe9b..87c686932 100644 --- a/core/error.rs +++ b/core/error.rs @@ -132,6 +132,8 @@ pub enum CompletionError { expected: u64, actual: u64, }, + #[error("tursodb not compiled with checksum feature")] + ChecksumNotEnabled, } #[macro_export] diff --git a/core/storage/checksum.rs b/core/storage/checksum.rs index e7ba78975..a67376048 100644 --- a/core/storage/checksum.rs +++ b/core/storage/checksum.rs @@ -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")] diff --git a/core/storage/database.rs b/core/storage/database.rs index c44aed214..79b7d0a7a 100644 --- a/core/storage/database.rs +++ b/core/storage/database.rs @@ -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, } } }