chore: set min version number (#5390)

* chore: set min version number

* chore: fix test
This commit is contained in:
Nathan.fooo 2024-05-22 14:24:11 +08:00 committed by GitHub
parent b2978e0d6c
commit 68c4e19f91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 37 additions and 17 deletions

View File

@ -94,6 +94,7 @@ flowy-notification = { path = "../../rust-lib/flowy-notification", features = [
uuid = "1.5.0" uuid = "1.5.0"
tauri-plugin-deep-link = "0.1.2" tauri-plugin-deep-link = "0.1.2"
dotenv = "0.15.0" dotenv = "0.15.0"
semver = "1.0.23"
[features] [features]
# by default Tauri runs in production mode # by default Tauri runs in production mode

View File

@ -34,7 +34,8 @@ pub fn init_flowy_core() -> AppFlowyCore {
.version .version
.clone() .clone()
.map(|v| v.to_string()) .map(|v| v.to_string())
.unwrap_or_else(|| "0.0.0".to_string()); .unwrap_or_else(|| "0.5.8".to_string());
let app_version = semver::Version::parse(&app_version).unwrap_or_else(|_| semver::Version::new(0, 5, 8));
let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap(); let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap();
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
data_path.push("data_dev"); data_path.push("data_dev");

View File

@ -93,6 +93,7 @@ flowy-notification = { path = "../../rust-lib/flowy-notification", features = [
uuid = "1.5.0" uuid = "1.5.0"
tauri-plugin-deep-link = "0.1.2" tauri-plugin-deep-link = "0.1.2"
dotenv = "0.15.0" dotenv = "0.15.0"
semver = "1.0.23"
[features] [features]
# by default Tauri runs in production mode # by default Tauri runs in production mode

View File

@ -30,6 +30,7 @@ pub fn init_flowy_core() -> AppFlowyCore {
let config: tauri_utils::config::Config = serde_json::from_str(config_json).unwrap(); let config: tauri_utils::config::Config = serde_json::from_str(config_json).unwrap();
let app_version = config.package.version.clone().map(|v| v.to_string()).unwrap_or_else(|| "0.0.0".to_string()); let app_version = config.package.version.clone().map(|v| v.to_string()).unwrap_or_else(|| "0.0.0".to_string());
let app_version = semver::Version::parse(&app_version).unwrap_or_else(|_| semver::Version::new(0, 5, 8));
let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap(); let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap();
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
data_path.push("data_dev"); data_path.push("data_dev");

View File

@ -1218,6 +1218,7 @@ dependencies = [
"lib-log", "lib-log",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"protobuf", "protobuf",
"semver",
"serde", "serde",
"serde_json", "serde_json",
"serde_repr", "serde_repr",
@ -1509,6 +1510,7 @@ dependencies = [
"parking_lot 0.12.1", "parking_lot 0.12.1",
"protobuf", "protobuf",
"rand 0.8.5", "rand 0.8.5",
"semver",
"serde", "serde",
"serde_json", "serde_json",
"strum", "strum",
@ -2035,6 +2037,7 @@ dependencies = [
"postgrest", "postgrest",
"rand 0.8.5", "rand 0.8.5",
"reqwest", "reqwest",
"semver",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror",
@ -4800,9 +4803,9 @@ dependencies = [
[[package]] [[package]]
name = "semver" name = "semver"
version = "1.0.22" version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "serde" name = "serde"

View File

@ -25,6 +25,7 @@ lazy_static = "1.4.0"
parking_lot.workspace = true parking_lot.workspace = true
tracing.workspace = true tracing.workspace = true
lib-log.workspace = true lib-log.workspace = true
semver = "1.0.22"
# workspace # workspace
lib-dispatch = { workspace = true } lib-dispatch = { workspace = true }

View File

@ -1,11 +1,11 @@
#![allow(clippy::not_unsafe_ptr_arg_deref)] #![allow(clippy::not_unsafe_ptr_arg_deref)]
use allo_isolate::Isolate; use allo_isolate::Isolate;
use std::sync::Arc;
use std::{ffi::CStr, os::raw::c_char};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use parking_lot::Mutex; use parking_lot::Mutex;
use semver::Version;
use std::sync::Arc;
use std::{ffi::CStr, os::raw::c_char};
use tracing::{debug, error, info, trace, warn}; use tracing::{debug, error, info, trace, warn};
use flowy_core::config::AppFlowyCoreConfig; use flowy_core::config::AppFlowyCoreConfig;
@ -67,8 +67,16 @@ pub extern "C" fn init_sdk(_port: i64, data: *mut c_char) -> i64 {
let _ = save_appflowy_cloud_config(&configuration.root, &configuration.appflowy_cloud_config); let _ = save_appflowy_cloud_config(&configuration.root, &configuration.appflowy_cloud_config);
} }
let mut app_version =
Version::parse(&configuration.app_version).unwrap_or_else(|_| Version::new(0, 5, 8));
let min_version = Version::new(0, 5, 8);
if app_version < min_version {
app_version = min_version;
}
let config = AppFlowyCoreConfig::new( let config = AppFlowyCoreConfig::new(
configuration.app_version, app_version,
configuration.custom_app_path, configuration.custom_app_path,
configuration.origin_app_path, configuration.origin_app_path,
configuration.device_id, configuration.device_id,

View File

@ -24,6 +24,7 @@ flowy-notification = { workspace = true }
anyhow.workspace = true anyhow.workspace = true
flowy-storage = { workspace = true } flowy-storage = { workspace = true }
flowy-search = { workspace = true } flowy-search = { workspace = true }
semver = "1.0.23"
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true

View File

@ -10,6 +10,7 @@ use std::time::Duration;
use nanoid::nanoid; use nanoid::nanoid;
use parking_lot::RwLock; use parking_lot::RwLock;
use semver::Version;
use tokio::select; use tokio::select;
use tokio::time::sleep; use tokio::time::sleep;
@ -55,7 +56,7 @@ impl EventIntegrationTest {
let device_id = uuid::Uuid::new_v4().to_string(); let device_id = uuid::Uuid::new_v4().to_string();
let config = AppFlowyCoreConfig::new( let config = AppFlowyCoreConfig::new(
"".to_string(), Version::new(0, 5, 8),
path.clone(), path.clone(),
path, path,
device_id, device_id,

View File

@ -2,6 +2,7 @@ use std::fmt;
use std::path::Path; use std::path::Path;
use base64::Engine; use base64::Engine;
use semver::Version;
use tracing::{error, info}; use tracing::{error, info};
use flowy_server_pub::af_cloud_config::AFCloudConfiguration; use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
@ -15,7 +16,7 @@ use crate::integrate::log::create_log_filter;
#[derive(Clone)] #[derive(Clone)]
pub struct AppFlowyCoreConfig { pub struct AppFlowyCoreConfig {
/// Different `AppFlowyCoreConfig` instance should have different name /// Different `AppFlowyCoreConfig` instance should have different name
pub(crate) app_version: String, pub(crate) app_version: Version,
pub name: String, pub name: String,
pub(crate) device_id: String, pub(crate) device_id: String,
pub platform: String, pub platform: String,
@ -75,7 +76,7 @@ fn make_user_data_folder(root: &str, url: &str) -> String {
impl AppFlowyCoreConfig { impl AppFlowyCoreConfig {
pub fn new( pub fn new(
app_version: String, app_version: Version,
custom_application_path: String, custom_application_path: String,
application_path: String, application_path: String,
device_id: String, device_id: String,

View File

@ -133,7 +133,7 @@ impl ServerProvider {
config, config,
*self.user_enable_sync.read(), *self.user_enable_sync.read(),
self.config.device_id.clone(), self.config.device_id.clone(),
&self.config.app_version, self.config.app_version.clone(),
self.user.clone(), self.user.clone(),
)); ));

View File

@ -3,7 +3,6 @@
use flowy_search::folder::indexer::FolderIndexManagerImpl; use flowy_search::folder::indexer::FolderIndexManagerImpl;
use flowy_search::services::manager::SearchManager; use flowy_search::services::manager::SearchManager;
use flowy_storage::ObjectStorageService; use flowy_storage::ObjectStorageService;
use semver::Version;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use std::time::Duration; use std::time::Duration;
use sysinfo::System; use sysinfo::System;
@ -106,13 +105,12 @@ impl AppFlowyCore {
let task_dispatcher = Arc::new(RwLock::new(task_scheduler)); let task_dispatcher = Arc::new(RwLock::new(task_scheduler));
runtime.spawn(TaskRunner::run(task_dispatcher.clone())); runtime.spawn(TaskRunner::run(task_dispatcher.clone()));
let app_version = Version::parse(&config.app_version).unwrap_or_else(|_| Version::new(0, 5, 4));
let user_config = UserConfig::new( let user_config = UserConfig::new(
&config.name, &config.name,
&config.storage_path, &config.storage_path,
&config.application_path, &config.application_path,
&config.device_id, &config.device_id,
app_version, config.app_version.clone(),
); );
let authenticate_user = Arc::new(AuthenticateUser::new( let authenticate_user = Arc::new(AuthenticateUser::new(

View File

@ -48,6 +48,7 @@ tokio-stream = { workspace = true, features = ["sync"] }
lib-dispatch = { workspace = true } lib-dispatch = { workspace = true }
yrs.workspace = true yrs.workspace = true
rand = "0.8.5" rand = "0.8.5"
semver = "1.0.23"
[dependencies.client-api] [dependencies.client-api]
workspace = true workspace = true

View File

@ -12,6 +12,7 @@ use client_api::ws::{
use client_api::{Client, ClientConfiguration}; use client_api::{Client, ClientConfiguration};
use flowy_storage::ObjectStorageService; use flowy_storage::ObjectStorageService;
use rand::Rng; use rand::Rng;
use semver::Version;
use tokio::select; use tokio::select;
use tokio::sync::{watch, Mutex}; use tokio::sync::{watch, Mutex};
use tokio_stream::wrappers::WatchStream; use tokio_stream::wrappers::WatchStream;
@ -53,7 +54,7 @@ impl AppFlowyCloudServer {
config: AFCloudConfiguration, config: AFCloudConfiguration,
enable_sync: bool, enable_sync: bool,
mut device_id: String, mut device_id: String,
client_version: &str, client_version: Version,
user: Arc<dyn ServerUser>, user: Arc<dyn ServerUser>,
) -> Self { ) -> Self {
// The device id can't be empty, so we generate a new one if it is. // The device id can't be empty, so we generate a new one if it is.
@ -70,7 +71,7 @@ impl AppFlowyCloudServer {
ClientConfiguration::default() ClientConfiguration::default()
.with_compression_buffer_size(10240) .with_compression_buffer_size(10240)
.with_compression_quality(8), .with_compression_quality(8),
client_version, &client_version.to_string(),
); );
let token_state_rx = api_client.subscribe_token_state(); let token_state_rx = api_client.subscribe_token_state();
let enable_sync = Arc::new(AtomicBool::new(enable_sync)); let enable_sync = Arc::new(AtomicBool::new(enable_sync));

View File

@ -1,4 +1,5 @@
use client_api::ClientConfiguration; use client_api::ClientConfiguration;
use semver::Version;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
@ -32,7 +33,7 @@ pub fn af_cloud_server(config: AFCloudConfiguration) -> Arc<AppFlowyCloudServer>
config, config,
true, true,
fake_device_id, fake_device_id,
"0.5.1", Version::new(0, 5, 8),
Arc::new(FakeServerUserImpl), Arc::new(FakeServerUserImpl),
)) ))
} }