Skip to content

Commit

Permalink
Refactor sync_local
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Feb 4, 2025
1 parent c05654e commit 7ad5a13
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 165 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ default-members = ["crates/shell", "crates/sqlite"]

[profile.dev]
panic = "abort"
strip = true

[profile.release]
panic = "abort"
Expand Down
7 changes: 1 addition & 6 deletions crates/core/src/bucket_priority.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use core::ops::RangeInclusive;

use serde::{de::Visitor, Deserialize};
use sqlite_nostd::ResultCode;

Expand All @@ -15,16 +13,13 @@ impl BucketPriority {
}

pub const HIGHEST: BucketPriority = BucketPriority(0);
pub const LOWEST: BucketPriority = BucketPriority(3);
}

impl TryFrom<i32> for BucketPriority {
type Error = SQLiteError;

fn try_from(value: i32) -> Result<Self, Self::Error> {
const VALID: RangeInclusive<i32> = (BucketPriority::HIGHEST.0)..=(BucketPriority::LOWEST.0);

if !VALID.contains(&value) {
if value < BucketPriority::HIGHEST.0 {
return Err(SQLiteError(
ResultCode::MISUSE,
Some("Invalid bucket priority".into()),
Expand Down
2 changes: 0 additions & 2 deletions crates/core/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ bucket_list(bucket, checksum) AS (
json_extract(json_each.value, '$.bucket') as bucket,
json_extract(json_each.value, '$.checksum') as checksum
FROM json_each(json_extract(?1, '$.buckets'))
WHERE IFNULL(json_extract(json_each.value, '$.priority'), 1) <=
IFNULL(json_extract(?1, '$.priority'), 3)
)
SELECT
bucket_list.bucket as bucket,
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/operations_vtab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extern "C" fn update(
let result = insert_operation(db, args[3].text());
vtab_result(vtab, result)
} else if op == "sync_local" {
let result = sync_local(db, args[3]);
let result = sync_local(db, &args[3]);
if let Ok(result_row) = result {
unsafe {
*p_row_id = result_row;
Expand Down
Loading

0 comments on commit 7ad5a13

Please sign in to comment.