Skip to content

Commit 7ad5a13

Browse files
committed
Refactor sync_local
1 parent c05654e commit 7ad5a13

File tree

7 files changed

+254
-165
lines changed

7 files changed

+254
-165
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ default-members = ["crates/shell", "crates/sqlite"]
99

1010
[profile.dev]
1111
panic = "abort"
12+
strip = true
1213

1314
[profile.release]
1415
panic = "abort"

crates/core/src/bucket_priority.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use core::ops::RangeInclusive;
2-
31
use serde::{de::Visitor, Deserialize};
42
use sqlite_nostd::ResultCode;
53

@@ -15,16 +13,13 @@ impl BucketPriority {
1513
}
1614

1715
pub const HIGHEST: BucketPriority = BucketPriority(0);
18-
pub const LOWEST: BucketPriority = BucketPriority(3);
1916
}
2017

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

2421
fn try_from(value: i32) -> Result<Self, Self::Error> {
25-
const VALID: RangeInclusive<i32> = (BucketPriority::HIGHEST.0)..=(BucketPriority::LOWEST.0);
26-
27-
if !VALID.contains(&value) {
22+
if value < BucketPriority::HIGHEST.0 {
2823
return Err(SQLiteError(
2924
ResultCode::MISUSE,
3025
Some("Invalid bucket priority".into()),

crates/core/src/checkpoint.rs

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ bucket_list(bucket, checksum) AS (
4040
json_extract(json_each.value, '$.bucket') as bucket,
4141
json_extract(json_each.value, '$.checksum') as checksum
4242
FROM json_each(json_extract(?1, '$.buckets'))
43-
WHERE IFNULL(json_extract(json_each.value, '$.priority'), 1) <=
44-
IFNULL(json_extract(?1, '$.priority'), 3)
4543
)
4644
SELECT
4745
bucket_list.bucket as bucket,

crates/core/src/operations_vtab.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ extern "C" fn update(
8484
let result = insert_operation(db, args[3].text());
8585
vtab_result(vtab, result)
8686
} else if op == "sync_local" {
87-
let result = sync_local(db, args[3]);
87+
let result = sync_local(db, &args[3]);
8888
if let Ok(result_row) = result {
8989
unsafe {
9090
*p_row_id = result_row;

0 commit comments

Comments
 (0)