mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-26 04:24:21 +01:00
Add checksums behind a feature flag
This commit is contained in:
6
.github/workflows/rust.yml
vendored
6
.github/workflows/rust.yml
vendored
@@ -42,10 +42,14 @@ jobs:
|
||||
run: |
|
||||
cargo test --features encryption --color=always --test integration_tests query_processing::encryption
|
||||
cargo test --features encryption --color=always --lib storage::encryption
|
||||
- name: Test Checksums
|
||||
run: |
|
||||
cargo test --features checksum --color=always --lib storage::checksum
|
||||
cargo test --features checksum --color=always --test integration_tests storage::checksum
|
||||
- name: Test
|
||||
env:
|
||||
RUST_LOG: ${{ runner.debug && 'turso_core::storage=trace' || '' }}
|
||||
run: cargo test --verbose
|
||||
run: cargo test --verbose --features checksum
|
||||
timeout-minutes: 20
|
||||
|
||||
clippy:
|
||||
|
||||
@@ -29,6 +29,7 @@ simulator = ["fuzz", "serde"]
|
||||
serde = ["dep:serde"]
|
||||
series = []
|
||||
encryption = []
|
||||
checksum = []
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
io-uring = { version = "0.7.5", optional = true }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(unused_variables, dead_code)]
|
||||
use crate::{CompletionError, Result};
|
||||
|
||||
const CHECKSUM_PAGE_SIZE: usize = 4096;
|
||||
@@ -12,6 +13,21 @@ impl ChecksumContext {
|
||||
ChecksumContext {}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "checksum"))]
|
||||
pub fn add_checksum_to_page(&self, _page: &mut [u8], _page_id: usize) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "checksum"))]
|
||||
pub fn verify_checksum(
|
||||
&self,
|
||||
_page: &mut [u8],
|
||||
_page_id: usize,
|
||||
) -> std::result::Result<(), CompletionError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "checksum")]
|
||||
pub fn add_checksum_to_page(&self, page: &mut [u8], _page_id: usize) -> Result<()> {
|
||||
if page.len() != CHECKSUM_PAGE_SIZE {
|
||||
return Ok(());
|
||||
@@ -27,6 +43,7 @@ impl ChecksumContext {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "checksum")]
|
||||
pub fn verify_checksum(
|
||||
&self,
|
||||
page: &mut [u8],
|
||||
|
||||
@@ -37,3 +37,4 @@ tracing = "0.1.41"
|
||||
|
||||
[features]
|
||||
encryption = ["turso_core/encryption"]
|
||||
checksum = ["turso_core/checksum"]
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#[cfg(feature = "checksum")]
|
||||
mod checksum;
|
||||
|
||||
Reference in New Issue
Block a user