Skip to content

Commit 6a36bcd

Browse files
authored
chore: add sqlite feature flag (#1683)
* chore: add sqlite feature flag * chore: fix clippy warings * ci: fix clippy * chore: add rev file persistence * ci: fix clippy Co-authored-by: nathan <[email protected]>
1 parent 860c5d1 commit 6a36bcd

File tree

74 files changed

+281
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+281
-226
lines changed

.github/workflows/rust_ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ jobs:
6666
working-directory: frontend/rust-lib/
6767

6868
- name: clippy rust-lib
69-
run: cargo clippy --no-default-features
69+
run: cargo clippy --features="rev-sqlite"
7070
working-directory: frontend/rust-lib
7171

7272
- name: Run rust-lib tests
7373
working-directory: frontend/rust-lib
74-
run: RUST_LOG=info cargo test --no-default-features --features="sync"
74+
run: RUST_LOG=info cargo test --no-default-features --features="sync,rev-sqlite"
7575

7676
- name: rustfmt shared-lib
7777
run: cargo fmt --all -- --check
7878
working-directory: shared-lib
7979

8080
- name: clippy shared-lib
81-
run: cargo clippy --no-default-features
81+
run: cargo clippy -- -D warnings
8282
working-directory: shared-lib
8383

8484
- name: Run shared-lib tests

frontend/Makefile.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
2323
CARGO_MAKE_CRATE_NAME = "dart-ffi"
2424
LIB_NAME = "dart_ffi"
2525
CURRENT_APP_VERSION = "0.0.9.1"
26-
FEATURES = "flutter"
26+
FLUTTER_DESKTOP_FEATURES = "flutter,rev-sqlite"
2727
PRODUCT_NAME = "AppFlowy"
2828
# CRATE_TYPE: https://doc.rust-lang.org/reference/linkage.html
2929
# If you update the macOS's CRATE_TYPE, don't forget to update the
@@ -150,7 +150,7 @@ script = ['''
150150
echo BUILD_FLAG: ${BUILD_FLAG}
151151
echo TARGET_OS: ${TARGET_OS}
152152
echo RUST_COMPILE_TARGET: ${RUST_COMPILE_TARGET}
153-
echo FEATURES: ${FEATURES}
153+
echo FEATURES: ${FLUTTER_DESKTOP_FEATURES}
154154
echo PRODUCT_EXT: ${PRODUCT_EXT}
155155
echo APP_ENVIRONMENT: ${APP_ENVIRONMENT}
156156
echo ${platforms}

frontend/rust-lib/Cargo.lock

Lines changed: 17 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/rust-lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
members = [
33
"lib-dispatch",
44
"lib-log",
5-
"lib-sqlite",
65
"flowy-net",
76
"flowy-core",
87
"dart-ffi",
@@ -14,6 +13,7 @@ members = [
1413
"flowy-document",
1514
"flowy-error",
1615
"flowy-revision",
16+
"flowy-revision-persistence",
1717
"flowy-grid",
1818
"flowy-task",
1919
"flowy-sync",

frontend/rust-lib/dart-ffi/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ dart-notify = { path = "../dart-notify" }
3131
flowy-derive = { path = "../flowy-derive" }
3232

3333
[features]
34-
default = ["flowy-core/dart", "flutter"]
34+
default = ["flowy-core/dart", "flutter", "rev-sqlite"]
3535
flutter = []
36+
rev-sqlite = ["flowy-core/rev-sqlite"]
3637
http_sync = ["flowy-core/http_sync", "flowy-core/use_bunyan"]
3738
openssl_vendored = ["flowy-core/openssl_vendored"]
3839

frontend/rust-lib/flowy-core/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ flowy-net = { path = "../flowy-net" }
1313
flowy-folder = { path = "../flowy-folder", default-features = false }
1414
flowy-grid = { path = "../flowy-grid", default-features = false }
1515
grid-rev-model = { path = "../../../shared-lib/grid-rev-model" }
16-
flowy-database = { path = "../flowy-database" }
16+
flowy-database = { path = "../flowy-database", optional = true }
1717
flowy-document = { path = "../flowy-document", default-features = false }
1818
flowy-revision = { path = "../flowy-revision" }
1919
flowy-task = { path = "../flowy-task" }
@@ -39,4 +39,11 @@ dart = [
3939
"flowy-grid/dart",
4040
"flowy-document/dart",
4141
]
42+
rev-sqlite = [
43+
"flowy-database",
44+
"flowy-user/rev-sqlite",
45+
"flowy-folder/rev-sqlite",
46+
"flowy-grid/rev-sqlite",
47+
"flowy-document/rev-sqlite",
48+
]
4249
openssl_vendored = ["flowy-database/openssl_vendored"]

frontend/rust-lib/flowy-core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl FlowySDKConfig {
7979
fn crate_log_filter(level: String) -> String {
8080
let level = std::env::var("RUST_LOG").unwrap_or(level);
8181
let mut filters = vec![];
82-
filters.push(format!("flowy_sdk={}", level));
82+
filters.push(format!("flowy_core={}", level));
8383
filters.push(format!("flowy_folder={}", level));
8484
filters.push(format!("flowy_user={}", level));
8585
filters.push(format!("flowy_document={}", level));
@@ -95,7 +95,7 @@ fn crate_log_filter(level: String) -> String {
9595
// filters.push(format!("lib_dispatch={}", level));
9696

9797
filters.push(format!("dart_ffi={}", "info"));
98-
filters.push(format!("flowy_database={}", level));
98+
filters.push(format!("flowy_database={}", "info"));
9999
filters.push(format!("flowy_net={}", "info"));
100100
filters.join(",")
101101
}

frontend/rust-lib/flowy-database/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ edition = "2018"
99
diesel = { version = "1.4.8", features = ["sqlite"] }
1010
diesel_derives = { version = "1.4.1", features = ["sqlite"] }
1111
diesel_migrations = { version = "1.4.0", features = ["sqlite"] }
12-
lib-sqlite = { path = "../lib-sqlite" }
1312
tracing = { version = "0.1", features = ["log"] }
1413
lazy_static = "1.4.0"
1514

15+
r2d2 = "0.8.9"
16+
libsqlite3-sys = { version = ">=0.8.0, <0.24.0", features = ["bundled"] }
17+
scheduled-thread-pool = "0.2.5"
18+
error-chain = "=0.12.0"
19+
openssl = { version = "0.10.38", optional = true }
20+
1621
[features]
17-
openssl_vendored = ["lib-sqlite/openssl_vendored"]
22+
openssl_vendored = ["openssl/vendored"]

frontend/rust-lib/flowy-database/src/kv/kv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::kv::schema::{kv_table, kv_table::dsl, KV_SQL};
2+
use crate::sqlite::{DBConnection, Database, PoolConfig};
23
use ::diesel::{query_dsl::*, ExpressionMethods};
34
use diesel::{Connection, SqliteConnection};
45
use lazy_static::lazy_static;
5-
use lib_sqlite::{DBConnection, Database, PoolConfig};
66
use std::{path::Path, sync::RwLock};
77

88
macro_rules! impl_get_func {

frontend/rust-lib/flowy-database/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ pub use diesel_derives::*;
33
use diesel_migrations::*;
44
use std::{fmt::Debug, io, path::Path};
55
pub mod kv;
6+
mod sqlite;
7+
8+
use crate::sqlite::PoolConfig;
9+
pub use crate::sqlite::{ConnectionPool, DBConnection, Database};
610

7-
use lib_sqlite::PoolConfig;
8-
pub use lib_sqlite::{ConnectionPool, DBConnection, Database};
911
pub mod schema;
1012

1113
#[macro_use]
1214
pub mod macros;
15+
1316
#[macro_use]
1417
extern crate diesel;
1518
#[macro_use]
@@ -41,7 +44,7 @@ pub fn init(storage_path: &str) -> Result<Database, io::Error> {
4144

4245
fn as_io_error<E>(e: E) -> io::Error
4346
where
44-
E: Into<lib_sqlite::Error> + Debug,
47+
E: Into<crate::sqlite::Error> + Debug,
4548
{
4649
let msg = format!("{:?}", e);
4750
io::Error::new(io::ErrorKind::NotConnected, msg)

0 commit comments

Comments
 (0)