From e207c761a7266a842066c45df2f0cfd57cf2d958 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Mon, 30 Jun 2025 15:11:01 +0800 Subject: [PATCH 01/12] adapt new conntext api --- monobean/Cargo.toml | 1 + monobean/src/core/mega_core.rs | 58 +++++++++++++++++++++++----------- monobean/src/core/servers.rs | 9 +++--- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/monobean/Cargo.toml b/monobean/Cargo.toml index 21f621928..9d5a4e9f1 100644 --- a/monobean/Cargo.toml +++ b/monobean/Cargo.toml @@ -25,6 +25,7 @@ vault = { path = "../vault" } gateway = { path = "../gateway" } ceres = { path = "../ceres" } mercury = { path = "../mercury" } +context = {path = "../context"} thiserror = { version = "2.0.11", features = ["default"] } tracing-subscriber = { version = "0.3.19", features = ["default", "env-filter"] } diff --git a/monobean/src/core/mega_core.rs b/monobean/src/core/mega_core.rs index cadba8386..4eeaa1098 100644 --- a/monobean/src/core/mega_core.rs +++ b/monobean/src/core/mega_core.rs @@ -9,7 +9,8 @@ use ceres::api_service::ApiHandler; use ceres::protocol::repo::Repo; use common::config::Config; use common::model::P2pOptions; -use jupiter::context::Context as MegaContext; +// use jupiter::context::Context as MegaContext; +use context::AppContext as MegaContext; use mercury::internal::object::tree::Tree; use std::fmt; use std::fmt::{Debug, Formatter}; @@ -19,6 +20,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use tokio::sync::{oneshot, OnceCell, RwLock}; use vault::pgp::{SignedPublicKey, SignedSecretKey}; +use vault::integration::vault_core::VaultCore; pub struct MegaCore { config: Arc>, @@ -145,20 +147,30 @@ impl MegaCore { chan.send(Err(MonoBeanError::ReinitError)).unwrap(); return; } + + + let guard = self.running_context.read().await; + let vault_core = if let Some(ctx) = guard.as_ref() { + &ctx.vault + } else { + return; + }; + + - if let Some(pk) = vault::pgp::load_pub_key().await { - let sk = vault::pgp::load_sec_key().await.unwrap(); + if let Some(pk) = vault_core.load_pub_key() { + let sk = vault_core.load_sec_key().await.unwrap(); chan.send(Ok(())).unwrap(); self.pgp.set((pk, sk)).unwrap(); } else { let uid = format!("{} <{}>", user_name, user_email); - let params = vault::pgp::params( + let params = VaultCore::params( vault::pgp::KeyType::Rsa(2048), passwd.clone(), uid.as_ref(), ); - let (pk, sk) = vault::pgp::gen_pgp_keypair(params, passwd); - vault::pgp::save_keys(pk.clone(), sk.clone()).await; + let (pk, sk) = vault_core.gen_pgp_keypair(params, passwd); + vault_core.save_keys(pk.clone(), sk.clone()); chan.send(Ok(())).unwrap(); self.pgp.set((pk, sk)).unwrap(); } @@ -190,9 +202,16 @@ impl MegaCore { self.initialized.store(true, Ordering::Release); } + let guard = self.running_context.read().await; + let vault_core = if let Some(ctx) = guard.as_ref() { + &ctx.vault + } else { + return; + }; + // Try to load pgp keys from vault. - if let Some(pk) = vault::pgp::load_pub_key().await { - let sk = vault::pgp::load_sec_key().await.unwrap(); + if let Some(pk) = vault_core.load_pub_key(){ + let sk = vault_core.load_sec_key().await.unwrap(); self.pgp.set((pk, sk)).unwrap(); tracing::debug!("Loaded pgp keys from vault"); } @@ -211,13 +230,14 @@ impl MegaCore { return Err(MonoBeanError::MegaCoreError(err.to_string())); } - let config: Arc = self.config.read().await.clone().into(); + // let config: Arc = self.config.read().await.clone().into(); + let config = self.config.read().await.clone(); let inner = MegaContext::new(config.clone()).await; - inner - .services - .mono_storage - .init_monorepo(&config.monorepo) - .await; + // inner + // .services + // .mono_storage + // .init_monorepo(&config.monorepo) + // .await; let http_ctx = inner.clone(); *self.http_options.write().await = http_addr @@ -281,7 +301,8 @@ impl MegaCore { if path.as_ref().starts_with(&import_dir) && path.as_ref() != import_dir { if let Some(model) = ctx - .services + .storage + .services.as_ref() .git_db_storage .find_git_repo_like_path(path.as_ref().to_string_lossy().as_ref()) .await @@ -289,13 +310,13 @@ impl MegaCore { { let repo: Repo = model.into(); return Ok(Box::new(ImportApiService { - context: ctx.clone(), + storage: ctx.storage.clone(), repo, })); } } let ret: Box = Box::new(MonoApiService { - context: ctx.clone(), + storage: ctx.storage.clone(), }); // Rust-analyzer cannot infer the type of `ret` correctly and always reports an error. @@ -328,7 +349,7 @@ impl MegaCore { async fn load_blob(&self, id: impl AsRef) -> MonoBeanResult { let ctx = self.running_context.read().await.clone().unwrap(); - let mono = MonoApiService { context: ctx }; + let mono = MonoApiService {storage: ctx.storage }; let raw = mono .get_raw_blob_by_hash(id.as_ref()) .await @@ -500,6 +521,7 @@ mod tests { #[tokio::test] async fn test_launch_http() { let temp_base = TempDir::new().unwrap(); + let core = test_core(&temp_base).await; core.process_command(MegaCommands::MegaStart( Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 8080)), diff --git a/monobean/src/core/servers.rs b/monobean/src/core/servers.rs index 4c8358489..e38460a4b 100644 --- a/monobean/src/core/servers.rs +++ b/monobean/src/core/servers.rs @@ -2,7 +2,8 @@ use crate::error::MonoBeanResult; use bytes::BytesMut; use common::model::P2pOptions; use gateway::https_server::{app, check_run_with_p2p}; -use jupiter::context::Context as MegaContext; +// use jupiter::context::Context as MegaContext; +use context::AppContext as MegaContext; use mono::git_protocol::ssh::SshServer; use russh::server::Server; use std::collections::HashMap; @@ -31,7 +32,7 @@ impl HttpOptions { pub async fn run_server(&self, mega_ctx: MegaContext) -> MonoBeanResult<()> { let app = app( - mega_ctx.clone(), + mega_ctx.storage.clone(), self.addr.ip().to_string(), self.addr.port(), self.p2p.clone(), @@ -88,7 +89,7 @@ impl SshOptions { // Use rusty vault configurations... let (tx, mut rx) = mpsc::channel::<()>(1); self.abort.set(tx).unwrap(); - let key = mono::server::ssh_server::load_key().await; + let key = mono::server::ssh_server::load_key(mega_ctx.clone()); let ssh_config = russh::server::Config { auth_rejection_time: std::time::Duration::from_secs(3), keys: vec![key], @@ -100,7 +101,7 @@ impl SshOptions { let mut ssh_server = SshServer { clients: Arc::new(Mutex::new(HashMap::new())), id: 0, - context: mega_ctx, + storage: mega_ctx.storage.clone(), smart_protocol: None, data_combined: BytesMut::new(), }; From a57c092308fa846acbfe080d76ee2c83f0bdee31 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Mon, 30 Jun 2025 22:36:46 +0800 Subject: [PATCH 02/12] =?UTF-8?q?monobean=EF=BC=9Aadapt=20new=20context=20?= =?UTF-8?q?api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- context/Cargo.toml | 1 + context/src/lib.rs | 13 +++++++- monobean/src/core/mega_core.rs | 49 ++++++++++++++++++++++++----- vault/src/integration/vault_core.rs | 35 +++++++++++++++------ 4 files changed, 80 insertions(+), 18 deletions(-) diff --git a/context/Cargo.toml b/context/Cargo.toml index 7c7419019..d88453ba2 100644 --- a/context/Cargo.toml +++ b/context/Cargo.toml @@ -17,3 +17,4 @@ jupiter = { workspace = true } vault = { workspace = true } gemini = { workspace = true, optional = true } +tokio = "1.45.1" diff --git a/context/src/lib.rs b/context/src/lib.rs index b168e19a0..a22e49117 100644 --- a/context/src/lib.rs +++ b/context/src/lib.rs @@ -22,9 +22,17 @@ pub struct AppContext { impl AppContext { /// Creates a new application context with the given configuration. pub async fn new(config: common::config::Config) -> Self { + let config = Arc::new(config); + let storage = jupiter::storage::Storage::new(config.clone()).await; - let vault = vault::integration::vault_core::VaultCore::new(storage.clone()); + + let storage_for_vault = storage.clone(); + let vault = tokio::task::spawn_blocking(move || { + vault::integration::vault_core::VaultCore::new(storage_for_vault) + }).await.expect("VaultCore::new panicked"); + + #[cfg(feature = "p2p")] let client = gemini::p2p::client::P2PClient::new(storage.clone(), vault.clone()); @@ -41,9 +49,12 @@ impl AppContext { #[cfg(feature = "p2p")] client, } + + } pub fn wrapped_context(&self) -> Arc { Arc::new(self.clone()) } } + diff --git a/monobean/src/core/mega_core.rs b/monobean/src/core/mega_core.rs index 4eeaa1098..e753a8950 100644 --- a/monobean/src/core/mega_core.rs +++ b/monobean/src/core/mega_core.rs @@ -201,7 +201,7 @@ impl MegaCore { } else { self.initialized.store(true, Ordering::Release); } - + let guard = self.running_context.read().await; let vault_core = if let Some(ctx) = guard.as_ref() { &ctx.vault @@ -229,16 +229,17 @@ impl MegaCore { tracing::error!(err); return Err(MonoBeanError::MegaCoreError(err.to_string())); } - + // let config: Arc = self.config.read().await.clone().into(); let config = self.config.read().await.clone(); + let inner = MegaContext::new(config.clone()).await; // inner // .services // .mono_storage // .init_monorepo(&config.monorepo) // .await; - + let http_ctx = inner.clone(); *self.http_options.write().await = http_addr .map(|addr| HttpOptions::new(addr, p2p_opt)) @@ -255,7 +256,7 @@ impl MegaCore { } } }); - + let ssh_ctx = inner.clone(); let ssh_opt = ssh_addr.map(SshOptions::new).or(None); *self.ssh_options.write().await = ssh_opt; @@ -271,7 +272,7 @@ impl MegaCore { } } }); - + *self.running_context.write().await = Some(inner); Ok(()) } @@ -476,6 +477,7 @@ mod tests { use std::net::{IpAddr, Ipv4Addr}; use tempfile::TempDir; + async fn test_core(temp_base: &TempDir) -> MegaCore { let (tx, _) = bounded(1); let (_, cmd_rx) = bounded(1); @@ -495,6 +497,7 @@ mod tests { }; let core = MegaCore::new(tx, cmd_rx, config); + println!("core start ok"); core.init().await; core } @@ -520,9 +523,13 @@ mod tests { #[tokio::test] async fn test_launch_http() { - let temp_base = TempDir::new().unwrap(); + let temp_base = TempDir::new().unwrap(); + let core = test_core(&temp_base).await; + println!("temp_base: {:?}", temp_base.path()); + + core.process_command(MegaCommands::MegaStart( Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 8080)), None, @@ -531,7 +538,7 @@ mod tests { .await; assert!(core.http_options.read().await.is_some()); assert!(!core.ssh_options.read().await.is_some()); - + core.process_command(MegaCommands::MegaShutdown).await; assert!(core.http_options.read().await.is_none()); assert!(core.ssh_options.read().await.is_none()); @@ -557,4 +564,32 @@ mod tests { #[tokio::test] async fn test_run_with_config() {} + + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] + async fn test_mega_context_new() { + // 创建临时目录作为 base_dir + let temp_base = TempDir::new().unwrap(); + + // 构造一个简单的 Config + let config = Config { + base_dir: temp_base.path().to_path_buf(), + log: LogConfig { + log_path: temp_base.path().to_path_buf(), + level: "debug".to_string(), + print_std: true, + }, + database: DbConfig { + db_type: "sqlite".to_string(), + db_path: temp_base.path().to_path_buf().join("test.db"), + ..Default::default() + }, + ..Default::default() + }; + + eprintln!("排查阻塞"); + // 调用 MegaContext::new + let ctx = MegaContext::new(config).await; + + + } } diff --git a/vault/src/integration/vault_core.rs b/vault/src/integration/vault_core.rs index ee07f5651..0e807330e 100644 --- a/vault/src/integration/vault_core.rs +++ b/vault/src/integration/vault_core.rs @@ -1,8 +1,5 @@ -use std::{ - path::PathBuf, - sync::{Arc, RwLock}, -}; - +use std::{path::PathBuf, result, sync::{Arc, RwLock}}; +use std::sync::{Mutex, OnceLock}; use crate::integration::jupiter_backend::JupiterBackend; use common::errors::MegaError; use jupiter::storage::Storage; @@ -18,6 +15,8 @@ use tracing::log; const CORE_KEY_FILE: &str = "core_key.json"; // where the core key is stored, like `root_token` + + #[derive(Debug, Clone, Serialize, Deserialize)] struct CoreKey { secret_shares: Vec>, @@ -51,9 +50,10 @@ impl VaultCore { pub fn new(ctx: Storage) -> Self { let dir = common::config::mega_base().join("vault"); let key_path = dir.join(CORE_KEY_FILE); - + println!("{:?}", key_path); std::fs::create_dir_all(&dir).expect("Failed to create vault directory"); - Self::config(ctx, key_path) + let result = Self::config(ctx.clone(), key_path); + result } fn config(ctx: Storage, key_path: PathBuf) -> Self { @@ -71,6 +71,7 @@ impl VaultCore { }; let core = Arc::new(RwLock::new(core)); + let key = { let mut managed_core = core.write().unwrap(); managed_core @@ -78,6 +79,9 @@ impl VaultCore { .expect("Failed to configure vault core"); let core_key = if !key_path.exists() { + + let _guard = INIT_MUTEX.get_or_init(|| Mutex::new(())).lock().unwrap(); + let result = managed_core .init(&seal_config) .expect("Failed to initialize vault"); @@ -85,9 +89,9 @@ impl VaultCore { secret_shares: Vec::from(&result.secret_shares[..]), root_token: result.root_token, }; - let file = std::fs::File::create(key_path).unwrap(); + println!("[vault] Creating new core_key.json at: {}", key_path.display()); + let file = std::fs::File::create(&key_path).unwrap(); serde_json::to_writer_pretty(file, &core_key).unwrap(); - core_key } else { println!("Using existing vault core key file: {}", key_path.display()); @@ -110,7 +114,6 @@ impl VaultCore { core_key.into() }; - Self { core, key } } } @@ -182,11 +185,13 @@ mod tests { use super::*; use std::collections::HashMap; + use tempfile::TempDir; #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_vault_core_initialization() { let temp_dir = tempfile::tempdir().expect("Failed to create temporary directory"); let key_path = temp_dir.path().join(CORE_KEY_FILE); + println!("Key path: {:?}", key_path); let storage = test_storage(temp_dir.path()).await; let vault_core = VaultCore::config(storage, key_path); @@ -200,6 +205,16 @@ mod tests { ); } + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] + async fn test_vault_core_new() { + let temp_dir = tempfile::tempdir().expect("Failed to create temporary directory"); + let key_path = temp_dir.path().join(CORE_KEY_FILE); + println!("Key path: {:?}", key_path); + let storage = test_storage(temp_dir.path()).await; + let vault_core = VaultCore::new(storage); + + } + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_vault_api() { let temp_dir = tempfile::tempdir().expect("Failed to create temporary directory"); From 66c0094c37854aa63de23f464c2a2953ab032317 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Tue, 1 Jul 2025 08:56:51 +0800 Subject: [PATCH 03/12] passed unit tests --- monobean/src/core/mega_core.rs | 44 ++++++----------------------- monobean/src/core/servers.rs | 1 - vault/src/integration/vault_core.rs | 16 ++--------- 3 files changed, 10 insertions(+), 51 deletions(-) diff --git a/monobean/src/core/mega_core.rs b/monobean/src/core/mega_core.rs index e753a8950..dfd56b38d 100644 --- a/monobean/src/core/mega_core.rs +++ b/monobean/src/core/mega_core.rs @@ -9,7 +9,6 @@ use ceres::api_service::ApiHandler; use ceres::protocol::repo::Repo; use common::config::Config; use common::model::P2pOptions; -// use jupiter::context::Context as MegaContext; use context::AppContext as MegaContext; use mercury::internal::object::tree::Tree; use std::fmt; @@ -153,6 +152,8 @@ impl MegaCore { let vault_core = if let Some(ctx) = guard.as_ref() { &ctx.vault } else { + let err_msg = "Mega core is not running, failed to get vault core"; + tracing::error!(err_msg); return; }; @@ -206,7 +207,9 @@ impl MegaCore { let vault_core = if let Some(ctx) = guard.as_ref() { &ctx.vault } else { - return; + let err_msg = "Mega core is not running, failed to get vault core"; + tracing::error!(err_msg); + return ; }; // Try to load pgp keys from vault. @@ -230,15 +233,11 @@ impl MegaCore { return Err(MonoBeanError::MegaCoreError(err.to_string())); } - // let config: Arc = self.config.read().await.clone().into(); + let config = self.config.read().await.clone(); let inner = MegaContext::new(config.clone()).await; - // inner - // .services - // .mono_storage - // .init_monorepo(&config.monorepo) - // .await; + let http_ctx = inner.clone(); *self.http_options.write().await = http_addr @@ -564,32 +563,5 @@ mod tests { #[tokio::test] async fn test_run_with_config() {} - - #[tokio::test(flavor = "multi_thread", worker_threads = 1)] - async fn test_mega_context_new() { - // 创建临时目录作为 base_dir - let temp_base = TempDir::new().unwrap(); - - // 构造一个简单的 Config - let config = Config { - base_dir: temp_base.path().to_path_buf(), - log: LogConfig { - log_path: temp_base.path().to_path_buf(), - level: "debug".to_string(), - print_std: true, - }, - database: DbConfig { - db_type: "sqlite".to_string(), - db_path: temp_base.path().to_path_buf().join("test.db"), - ..Default::default() - }, - ..Default::default() - }; - - eprintln!("排查阻塞"); - // 调用 MegaContext::new - let ctx = MegaContext::new(config).await; - - - } + } diff --git a/monobean/src/core/servers.rs b/monobean/src/core/servers.rs index e38460a4b..add57415f 100644 --- a/monobean/src/core/servers.rs +++ b/monobean/src/core/servers.rs @@ -2,7 +2,6 @@ use crate::error::MonoBeanResult; use bytes::BytesMut; use common::model::P2pOptions; use gateway::https_server::{app, check_run_with_p2p}; -// use jupiter::context::Context as MegaContext; use context::AppContext as MegaContext; use mono::git_protocol::ssh::SshServer; use russh::server::Server; diff --git a/vault/src/integration/vault_core.rs b/vault/src/integration/vault_core.rs index 0e807330e..ca24c9d82 100644 --- a/vault/src/integration/vault_core.rs +++ b/vault/src/integration/vault_core.rs @@ -1,5 +1,4 @@ -use std::{path::PathBuf, result, sync::{Arc, RwLock}}; -use std::sync::{Mutex, OnceLock}; +use std::{path::PathBuf, sync::{Arc, RwLock}}; use crate::integration::jupiter_backend::JupiterBackend; use common::errors::MegaError; use jupiter::storage::Storage; @@ -80,7 +79,6 @@ impl VaultCore { let core_key = if !key_path.exists() { - let _guard = INIT_MUTEX.get_or_init(|| Mutex::new(())).lock().unwrap(); let result = managed_core .init(&seal_config) @@ -185,7 +183,6 @@ mod tests { use super::*; use std::collections::HashMap; - use tempfile::TempDir; #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_vault_core_initialization() { @@ -204,16 +201,7 @@ mod tests { "Vault core should be initialized" ); } - - #[tokio::test(flavor = "multi_thread", worker_threads = 1)] - async fn test_vault_core_new() { - let temp_dir = tempfile::tempdir().expect("Failed to create temporary directory"); - let key_path = temp_dir.path().join(CORE_KEY_FILE); - println!("Key path: {:?}", key_path); - let storage = test_storage(temp_dir.path()).await; - let vault_core = VaultCore::new(storage); - - } + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_vault_api() { From 6a4e533729293a2d7d65b80262fa1fc661a0e868 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Tue, 1 Jul 2025 13:25:58 +0800 Subject: [PATCH 04/12] fix clippy erro --- context/src/lib.rs | 2 +- monobean/src/application.rs | 2 +- monobean/src/components/hello_page.rs | 4 +- monobean/src/config.rs | 4 +- monobean/src/core/mega_core.rs | 72 +++++++++++++-------------- monobean/src/core/servers.rs | 2 +- monobean/src/window.rs | 2 +- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/context/src/lib.rs b/context/src/lib.rs index a22e49117..bdeca9250 100644 --- a/context/src/lib.rs +++ b/context/src/lib.rs @@ -30,7 +30,7 @@ impl AppContext { let storage_for_vault = storage.clone(); let vault = tokio::task::spawn_blocking(move || { vault::integration::vault_core::VaultCore::new(storage_for_vault) - }).await.expect("VaultCore::new panicked"); + }).await.expect("VaultCore::new panicked________"); #[cfg(feature = "p2p")] diff --git a/monobean/src/application.rs b/monobean/src/application.rs index 03cd320c1..9058346ea 100644 --- a/monobean/src/application.rs +++ b/monobean/src/application.rs @@ -294,7 +294,7 @@ impl MonobeanApplication { glib::LogLevel::Debug => tracing::Level::DEBUG, }; - println!("{}: {}", level, fields); + println!("{level}: {fields}"); }, ); } diff --git a/monobean/src/components/hello_page.rs b/monobean/src/components/hello_page.rs index 7af4792d6..dcc9a04cf 100644 --- a/monobean/src/components/hello_page.rs +++ b/monobean/src/components/hello_page.rs @@ -89,7 +89,7 @@ impl HelloPage { fn setup_logo(&self) { let logo = self.imp().logo.clone(); let id = random_int_range(1, 6); - logo.set_icon_name(Some(format!("walrus-{}", id).as_str())); + logo.set_icon_name(Some(format!("walrus-{id}").as_str())); let gesture = gtk::GestureClick::new(); gesture.connect_pressed(clone!( @@ -97,7 +97,7 @@ impl HelloPage { logo, move |_, _, _, _| { let id = random_int_range(1, 6); - logo.set_icon_name(Some(format!("walrus-{}", id).as_str())); + logo.set_icon_name(Some(format!("walrus-{id}").as_str())); } )); logo.add_controller(gesture); diff --git a/monobean/src/config.rs b/monobean/src/config.rs index 08f4de201..470a3eccd 100644 --- a/monobean/src/config.rs +++ b/monobean/src/config.rs @@ -95,7 +95,7 @@ macro_rules! get_setting { pub fn monobean_base() -> PathBuf { // Get the base directory from the environment variable or use the default std::env::var("MONOBEAN_BASE_DIR") - .map(|inner| PathBuf::from(inner)) + .map(PathBuf::from) .unwrap_or_else(|_| common::config::mega_base().join("monobean")) } @@ -119,7 +119,7 @@ pub fn monobean_base() -> PathBuf { pub fn monobean_cache() -> PathBuf { // Get the cache directory from the environment variable or use the default std::env::var("MONOBEAN_CACHE_DIR") - .map(|inner| PathBuf::from(inner)) + .map(PathBuf::from) .unwrap_or_else(|_| common::config::mega_cache().join("monobean")) } diff --git a/monobean/src/core/mega_core.rs b/monobean/src/core/mega_core.rs index dfd56b38d..0268396de 100644 --- a/monobean/src/core/mega_core.rs +++ b/monobean/src/core/mega_core.rs @@ -18,8 +18,8 @@ use std::path::{Component, Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use tokio::sync::{oneshot, OnceCell, RwLock}; -use vault::pgp::{SignedPublicKey, SignedSecretKey}; use vault::integration::vault_core::VaultCore; +use vault::pgp::{SignedPublicKey, SignedSecretKey}; pub struct MegaCore { config: Arc>, @@ -146,25 +146,22 @@ impl MegaCore { chan.send(Err(MonoBeanError::ReinitError)).unwrap(); return; } - - + let guard = self.running_context.read().await; let vault_core = if let Some(ctx) = guard.as_ref() { - &ctx.vault + &ctx.vault } else { let err_msg = "Mega core is not running, failed to get vault core"; tracing::error!(err_msg); return; }; - - if let Some(pk) = vault_core.load_pub_key() { let sk = vault_core.load_sec_key().await.unwrap(); chan.send(Ok(())).unwrap(); self.pgp.set((pk, sk)).unwrap(); } else { - let uid = format!("{} <{}>", user_name, user_email); + let uid = format!("{user_name} <{user_email}>"); let params = VaultCore::params( vault::pgp::KeyType::Rsa(2048), passwd.clone(), @@ -202,18 +199,18 @@ impl MegaCore { } else { self.initialized.store(true, Ordering::Release); } - + let guard = self.running_context.read().await; let vault_core = if let Some(ctx) = guard.as_ref() { - &ctx.vault - } else { - let err_msg = "Mega core is not running, failed to get vault core"; - tracing::error!(err_msg); - return ; - }; + &ctx.vault + } else { + let err_msg = "Mega core is not running, failed to get vault core"; + tracing::error!(err_msg); + return; + }; // Try to load pgp keys from vault. - if let Some(pk) = vault_core.load_pub_key(){ + if let Some(pk) = vault_core.load_pub_key() { let sk = vault_core.load_sec_key().await.unwrap(); self.pgp.set((pk, sk)).unwrap(); tracing::debug!("Loaded pgp keys from vault"); @@ -232,13 +229,11 @@ impl MegaCore { tracing::error!(err); return Err(MonoBeanError::MegaCoreError(err.to_string())); } - - + let config = self.config.read().await.clone(); - + let inner = MegaContext::new(config.clone()).await; - - + let http_ctx = inner.clone(); *self.http_options.write().await = http_addr .map(|addr| HttpOptions::new(addr, p2p_opt)) @@ -255,7 +250,7 @@ impl MegaCore { } } }); - + let ssh_ctx = inner.clone(); let ssh_opt = ssh_addr.map(SshOptions::new).or(None); *self.ssh_options.write().await = ssh_opt; @@ -271,7 +266,7 @@ impl MegaCore { } } }); - + *self.running_context.write().await = Some(inner); Ok(()) } @@ -302,7 +297,8 @@ impl MegaCore { if path.as_ref().starts_with(&import_dir) && path.as_ref() != import_dir { if let Some(model) = ctx .storage - .services.as_ref() + .services + .as_ref() .git_db_storage .find_git_repo_like_path(path.as_ref().to_string_lossy().as_ref()) .await @@ -340,7 +336,7 @@ impl MegaCore { match tree { Ok(Some(tree)) => Ok(tree), _ => { - let err_msg = format!("Failed to load tree: {:?}", path); + let err_msg = format!("Failed to load tree: {path:?}"); tracing::error!(err_msg); Err(MonoBeanError::MegaCoreError(err_msg)) } @@ -349,7 +345,9 @@ impl MegaCore { async fn load_blob(&self, id: impl AsRef) -> MonoBeanResult { let ctx = self.running_context.read().await.clone().unwrap(); - let mono = MonoApiService {storage: ctx.storage }; + let mono = MonoApiService { + storage: ctx.storage, + }; let raw = mono .get_raw_blob_by_hash(id.as_ref()) .await @@ -359,7 +357,7 @@ impl MegaCore { Some(data) => match String::from_utf8(data) { Ok(string) => Ok(string), Err(err) => { - let err_msg = format!("Invalid UTF-8 data: {}", err); + let err_msg = format!("Invalid UTF-8 data: {err}"); tracing::error!(err_msg); Err(MonoBeanError::MegaCoreError(err_msg)) } @@ -476,7 +474,6 @@ mod tests { use std::net::{IpAddr, Ipv4Addr}; use tempfile::TempDir; - async fn test_core(temp_base: &TempDir) -> MegaCore { let (tx, _) = bounded(1); let (_, cmd_rx) = bounded(1); @@ -496,7 +493,6 @@ mod tests { }; let core = MegaCore::new(tx, cmd_rx, config); - println!("core start ok"); core.init().await; core } @@ -522,13 +518,15 @@ mod tests { #[tokio::test] async fn test_launch_http() { - let temp_base = TempDir::new().unwrap(); - + + // 设置环境变量,让 mega_base() 返回临时目录 + unsafe { + std::env::set_var("MEGA_BASE_DIR", temp_base.path()); + } + let core = test_core(&temp_base).await; - println!("temp_base: {:?}", temp_base.path()); - - + core.process_command(MegaCommands::MegaStart( Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 8080)), None, @@ -537,15 +535,18 @@ mod tests { .await; assert!(core.http_options.read().await.is_some()); assert!(!core.ssh_options.read().await.is_some()); - + core.process_command(MegaCommands::MegaShutdown).await; assert!(core.http_options.read().await.is_none()); assert!(core.ssh_options.read().await.is_none()); } - #[tokio::test] + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_launch_ssh() { let temp_base = TempDir::new().unwrap(); + unsafe { + std::env::set_var("MEGA_BASE_DIR", temp_base.path()); + } let core = test_core(&temp_base).await; core.process_command(MegaCommands::MegaStart( None, @@ -563,5 +564,4 @@ mod tests { #[tokio::test] async fn test_run_with_config() {} - } diff --git a/monobean/src/core/servers.rs b/monobean/src/core/servers.rs index add57415f..fe110a9d8 100644 --- a/monobean/src/core/servers.rs +++ b/monobean/src/core/servers.rs @@ -1,8 +1,8 @@ use crate::error::MonoBeanResult; use bytes::BytesMut; use common::model::P2pOptions; -use gateway::https_server::{app, check_run_with_p2p}; use context::AppContext as MegaContext; +use gateway::https_server::{app, check_run_with_p2p}; use mono::git_protocol::ssh::SshServer; use russh::server::Server; use std::collections::HashMap; diff --git a/monobean/src/window.rs b/monobean/src/window.rs index 3004e4bc6..0fb48cbe4 100644 --- a/monobean/src/window.rs +++ b/monobean/src/window.rs @@ -253,7 +253,7 @@ fn load_css() { .into_iter() .map(|f| { let provider = CssProvider::new(); - provider.load_from_resource(&format!("{}/css/{}", PREFIX, f)); + provider.load_from_resource(&format!("{PREFIX}/css/{f}")); style_context_add_provider_for_display( >k::gdk::Display::default().expect("Could not connect to a display."), &provider, From 8fbac478a73bab5efdc15faf68cd1b4242014bd5 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Tue, 1 Jul 2025 13:27:56 +0800 Subject: [PATCH 05/12] fix clippy erro --- context/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context/src/lib.rs b/context/src/lib.rs index bdeca9250..a22e49117 100644 --- a/context/src/lib.rs +++ b/context/src/lib.rs @@ -30,7 +30,7 @@ impl AppContext { let storage_for_vault = storage.clone(); let vault = tokio::task::spawn_blocking(move || { vault::integration::vault_core::VaultCore::new(storage_for_vault) - }).await.expect("VaultCore::new panicked________"); + }).await.expect("VaultCore::new panicked"); #[cfg(feature = "p2p")] From 3b5006a1d9565e3bf7ebad18d5211202ed588f55 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Tue, 1 Jul 2025 22:25:14 +0800 Subject: [PATCH 06/12] Add mock implementations for testing --- context/src/lib.rs | 35 +++++++++++++++++++++++++++++ monobean/Cargo.toml | 1 + monobean/src/core/mega_core.rs | 33 ++++++++++++++++++--------- vault/src/integration/vault_core.rs | 2 +- 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/context/src/lib.rs b/context/src/lib.rs index a22e49117..71fe64918 100644 --- a/context/src/lib.rs +++ b/context/src/lib.rs @@ -1,4 +1,5 @@ use std::sync::Arc; +use jupiter::tests::test_storage; /// This is the main application context for the Mono application. /// It holds shared state and configuration for the application. @@ -28,9 +29,13 @@ impl AppContext { let storage = jupiter::storage::Storage::new(config.clone()).await; let storage_for_vault = storage.clone(); + let vault = tokio::task::spawn_blocking(move || { vault::integration::vault_core::VaultCore::new(storage_for_vault) }).await.expect("VaultCore::new panicked"); + + + #[cfg(feature = "p2p")] @@ -56,5 +61,35 @@ impl AppContext { pub fn wrapped_context(&self) -> Arc { Arc::new(self.clone()) } + + pub async fn mock(config: common::config::Config) -> Self { + + let config = Arc::new(config); + + // use Existing test method + let storage = test_storage(config.base_dir.clone()).await; + + let storage_for_vault = storage.clone(); + let temp_dir = config.base_dir.clone().join("vault"); + let key_path = temp_dir.join("core_key.json"); + std::fs::create_dir_all(&temp_dir).expect("Mock: Failed to create vault dir"); + + let vault = tokio::task::spawn_blocking(move || { + vault::integration::vault_core::VaultCore::config(storage_for_vault, key_path) + }) + .await + .expect("VaultCore::config panicked"); + + #[cfg(feature = "p2p")] + let client = gemini::p2p::client::P2PClient::new(storage.clone(), vault.clone()); + + Self { + storage, + vault, + config, + #[cfg(feature = "p2p")] + client, + } + } } diff --git a/monobean/Cargo.toml b/monobean/Cargo.toml index 9d5a4e9f1..e6ed96f50 100644 --- a/monobean/Cargo.toml +++ b/monobean/Cargo.toml @@ -42,6 +42,7 @@ home = "0.5.11" smallvec = "1.14.0" directories = "6.0.0" tracing-appender = "0.2.3" +toml = "0.8.22" [build-dependencies] glib-build-tools = "0.20.0" diff --git a/monobean/src/core/mega_core.rs b/monobean/src/core/mega_core.rs index 0268396de..adb4621d4 100644 --- a/monobean/src/core/mega_core.rs +++ b/monobean/src/core/mega_core.rs @@ -232,6 +232,10 @@ impl MegaCore { let config = self.config.read().await.clone(); + #[cfg(test)] + let inner = MegaContext::mock(config.clone()).await; + + #[cfg(not(test))] let inner = MegaContext::new(config.clone()).await; let http_ctx = inner.clone(); @@ -467,10 +471,11 @@ mod tests { use crate::config::APP_NAME; use crate::config::MEGA_CONFIG_PATH; use async_channel::bounded; - use common::config::DbConfig; use common::config::LogConfig; + use common::config::{AuthConfig, DbConfig, LFSConfig, MonoConfig, PackConfig}; use gtk::gio; use gtk::glib; + use std::fs; use std::net::{IpAddr, Ipv4Addr}; use tempfile::TempDir; @@ -489,9 +494,22 @@ mod tests { db_path: temp_base.path().to_path_buf().join("test.db"), ..Default::default() }, - ..Default::default() + monorepo: MonoConfig::default(), + pack: PackConfig::default(), + authentication: AuthConfig::default(), + lfs: LFSConfig::default(), + oauth: None, + //..Default::default() }; + // make config saved in temp dir + let config_dir = temp_base.path().join("etc"); + fs::create_dir_all(&config_dir).unwrap(); + let config_path = config_dir.join("config.toml"); + let toml_str = toml::to_string(&config).unwrap(); + fs::write(&config_path, toml_str).unwrap(); + let config = Config::new(config_path.to_str().unwrap()).unwrap(); + let core = MegaCore::new(tx, cmd_rx, config); core.init().await; core @@ -520,11 +538,6 @@ mod tests { async fn test_launch_http() { let temp_base = TempDir::new().unwrap(); - // 设置环境变量,让 mega_base() 返回临时目录 - unsafe { - std::env::set_var("MEGA_BASE_DIR", temp_base.path()); - } - let core = test_core(&temp_base).await; core.process_command(MegaCommands::MegaStart( @@ -541,12 +554,10 @@ mod tests { assert!(core.ssh_options.read().await.is_none()); } - #[tokio::test(flavor = "multi_thread", worker_threads = 1)] + #[tokio::test] async fn test_launch_ssh() { let temp_base = TempDir::new().unwrap(); - unsafe { - std::env::set_var("MEGA_BASE_DIR", temp_base.path()); - } + let core = test_core(&temp_base).await; core.process_command(MegaCommands::MegaStart( None, diff --git a/vault/src/integration/vault_core.rs b/vault/src/integration/vault_core.rs index ca24c9d82..39c16fe0a 100644 --- a/vault/src/integration/vault_core.rs +++ b/vault/src/integration/vault_core.rs @@ -55,7 +55,7 @@ impl VaultCore { result } - fn config(ctx: Storage, key_path: PathBuf) -> Self { + pub fn config(ctx: Storage, key_path: PathBuf) -> Self { let backend: Arc = Arc::new(JupiterBackend::new(ctx)); let barrier = barrier_aes_gcm::AESGCMBarrier::new(Arc::clone(&backend)); let seal_config = rusty_vault::core::SealConfig { From 33ddc55a1a46567a29b26423f2ff52185c327815 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Fri, 18 Jul 2025 14:53:39 +0800 Subject: [PATCH 07/12] add mock test & fix theme selector button --- monobean/resources/gtk/theme_selector.ui | 6 ++-- ...rg.Web3Infrastructure.Monobean.gschema.xml | 3 +- monobean/src/window.rs | 30 ++++++++++++++++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/monobean/resources/gtk/theme_selector.ui b/monobean/resources/gtk/theme_selector.ui index b297f10fb..c1363ca98 100644 --- a/monobean/resources/gtk/theme_selector.ui +++ b/monobean/resources/gtk/theme_selector.ui @@ -17,7 +17,7 @@ light false - win.style-variant + style.style-variant 'system' Use system style monobean-lasso-select-symbolic @@ -30,7 +30,7 @@ false - win.style-variant + style.style-variant 'light' Light style monobean-lasso-select-symbolic @@ -44,7 +44,7 @@ light false - win.style-variant + style.style-variant 'dark' Dark style monobean-lasso-select-symbolic diff --git a/monobean/resources/org.Web3Infrastructure.Monobean.gschema.xml b/monobean/resources/org.Web3Infrastructure.Monobean.gschema.xml index c0db5a472..05d019b6d 100644 --- a/monobean/resources/org.Web3Infrastructure.Monobean.gschema.xml +++ b/monobean/resources/org.Web3Infrastructure.Monobean.gschema.xml @@ -18,7 +18,8 @@ - 'system' + + 'light' Settings theme diff --git a/monobean/src/window.rs b/monobean/src/window.rs index 0fb48cbe4..b456a2b93 100644 --- a/monobean/src/window.rs +++ b/monobean/src/window.rs @@ -8,7 +8,7 @@ use crate::components::{mega_tab::MegaTab, repo_tab::RepoTab}; use crate::config::PREFIX; use crate::CONTEXT; use adw::glib::Priority; -use adw::prelude::{Cast, ObjectExt, SettingsExtManual, ToValue}; +use adw::prelude::{ActionMapExt, Cast, ObjectExt, SettingsExt, SettingsExtManual, StaticVariantType, ToValue, ToVariant}; use adw::subclass::prelude::*; use adw::{gio, ColorScheme, StyleManager, Toast}; use gtk::gio::Settings; @@ -16,6 +16,7 @@ use gtk::glib; use gtk::prelude::{GtkWindowExt, WidgetExt}; use gtk::CompositeTemplate; use std::cell::OnceCell; +use gtk::gio::{SimpleAction, SimpleActionGroup}; glib::wrapper! { pub struct MonobeanWindow(ObjectSubclass) @@ -197,12 +198,37 @@ impl MonobeanWindow { } fn setup_widget(&self) { + + let imp = self.imp(); let prim_btn = imp.primary_menu_button.get(); let popover = prim_btn.popover().unwrap(); let popover = popover.downcast::().unwrap(); let theme = ThemeSelector::new(); popover.add_child(&theme, "theme"); + + // popoverMenu cont find win.(action) change the action group + let action_group = SimpleActionGroup::new(); + + // style-variant action + let settings = self.settings().clone(); + let action = SimpleAction::new_stateful( + "style-variant", + Some(&String::static_variant_type()), + &settings.string("style-variant").to_variant(), + ); + action.connect_activate(move |action, parameter| { + if let Some(param) = parameter { + let value = param.get::().unwrap(); + action.set_state(&value.to_variant()); + settings.set_string("style-variant", &value).expect("Failed to set style-variant in GSettings"); + } + }); + + + action_group.add_action(&action); + + popover.insert_action_group("style", Some(&action_group)); } pub fn add_toast(&self, message: String) { @@ -243,6 +269,8 @@ impl MonobeanWindow { Some(scheme.to_value()) }) .build(); + + } } From 58fc98a3375ead72ad7d677b4e49f9d8ac7e8f72 Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Fri, 18 Jul 2025 15:06:31 +0800 Subject: [PATCH 08/12] test --- monobean/resources/gschemas.compiled | Bin 0 -> 2764 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 monobean/resources/gschemas.compiled diff --git a/monobean/resources/gschemas.compiled b/monobean/resources/gschemas.compiled new file mode 100644 index 0000000000000000000000000000000000000000..f3a16f64796eeb072d3af3c985053c9ce0bf9b4b GIT binary patch literal 2764 zcmZWqTWl0n7(Sqda&1K}MQ&TPu#24CLTe<%XhQ^wmq-+aH#$3Wx-)ckW}ORdB^XQ; z>w|#N7}BUQQId*aynvuD@>rD+!vpYwAxNSkF$6Us2CUzAW_Brbny=rt-#K$G|M|~9 z>t8Se$M7PNK26{)iO!Bsy>Z~nUv+&An>6!1I9xz@ik*;KjfLKnt)0SPJAu;nbIx=Wt!zbEDWUvS119 zxiO=GK6M@ZRp2$$XgU?*Oj_HlKa#5&G2ZzY)9zII;8PDLf}?j^71-75I7J%sBR^ zo&bLzct7C$)7wg)n(G__9|o?xy?Y&f>dEkrgTDuww*GjLKJ_&C=fJaZc>mhpb<(G1 z{|q<}oSn9!g+BFE_#I#u`1*-YPtm8I4u2PT5U`HDq4!12eGP#R19Q7hZeoAx2KXny z!$AFl=l0U4X8&{GYe4h2kM5yQ&3Oe9s}2~vIB=6b^+foM;B~+s*OpzUPtEvj1n&e6 zo%!S{eQJ(B06q;|`eN0y^r;z#3*bM2t%ZYI=u>l@cu7nG4s1TUlspz^`=zv)xYhHrz*z-v$L*5^gd_4I*v0-gT0 z$?Q+fyd40)37lJYOy6H>p8JR3L%_UiyWU}cYMnpeVW8whc3hOE>nJahj)ig+<_xRs z=+Y%bDq$uyi?xI`h;;?8i#fm&pjwBPLi543z`ijW&T)I0~%U29Nb^#xP!q^W% zq52^xV0pH3N_INnPdp5)!*ubLkfveUO0Pt(!zptTX*q!?M79%HvSI{Lzurt3^}9-L zuYS$kbVxJZ$4J;8MykwTBl=&`A<>o*^uV8hy=421IG6K_p$t^X@jcU%3g0i;rYE7V zJgee6)h{Nu9H4viH+{^DFcp12!l%%vNYA&DZ3(`Q*InN< zT-y($)hkxEwd>wGs772nA)EuUPny2xDKo;-Lhb|Q1ij;2>`2Qm8`bn2J8oNRYpWhN ze9`Tbu3suSUP-@P%vnVl^;h(Y(CS1`x8jx>)wor#$P!WszbDq>g#qHgwjYe&1Jz*`oW#soLUgfeX8A(`hNs<)iGQ?*LEaJ)~CaH`ACUwH_U7P&F_Qhc-+Tt<|BK zFhuDZg*IX^O(F@RXyKZd-RO5s_m~5AZKM5p_1{@_bEU^a(o=-sOz*mQwjWS z$g$-a%Qu&20)@L6Vn2866oc2cA==lEY1fxG4IXC1+enkNEF{0XF*VnOON{nnQb($l VimMd2)vL16cW3(R8p`;w@Bfc$KimKS literal 0 HcmV?d00001 From bcdfac9e96e53b9aa6a9901486e3146168976e9d Mon Sep 17 00:00:00 2001 From: pleasedontbreak123 Date: Fri, 18 Jul 2025 16:07:30 +0800 Subject: [PATCH 09/12] add mock test & fix theme selector button --- monobean/src/window.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/monobean/src/window.rs b/monobean/src/window.rs index b456a2b93..ada5252fb 100644 --- a/monobean/src/window.rs +++ b/monobean/src/window.rs @@ -8,15 +8,18 @@ use crate::components::{mega_tab::MegaTab, repo_tab::RepoTab}; use crate::config::PREFIX; use crate::CONTEXT; use adw::glib::Priority; -use adw::prelude::{ActionMapExt, Cast, ObjectExt, SettingsExt, SettingsExtManual, StaticVariantType, ToValue, ToVariant}; +use adw::prelude::{ + ActionMapExt, Cast, ObjectExt, SettingsExt, SettingsExtManual, StaticVariantType, ToValue, + ToVariant, +}; use adw::subclass::prelude::*; use adw::{gio, ColorScheme, StyleManager, Toast}; use gtk::gio::Settings; +use gtk::gio::{SimpleAction, SimpleActionGroup}; use gtk::glib; use gtk::prelude::{GtkWindowExt, WidgetExt}; use gtk::CompositeTemplate; use std::cell::OnceCell; -use gtk::gio::{SimpleAction, SimpleActionGroup}; glib::wrapper! { pub struct MonobeanWindow(ObjectSubclass) @@ -198,8 +201,6 @@ impl MonobeanWindow { } fn setup_widget(&self) { - - let imp = self.imp(); let prim_btn = imp.primary_menu_button.get(); let popover = prim_btn.popover().unwrap(); @@ -221,11 +222,12 @@ impl MonobeanWindow { if let Some(param) = parameter { let value = param.get::().unwrap(); action.set_state(&value.to_variant()); - settings.set_string("style-variant", &value).expect("Failed to set style-variant in GSettings"); + settings + .set_string("style-variant", &value) + .expect("Failed to set style-variant in GSettings"); } }); - action_group.add_action(&action); popover.insert_action_group("style", Some(&action_group)); @@ -269,8 +271,6 @@ impl MonobeanWindow { Some(scheme.to_value()) }) .build(); - - } } From 910980d6de9dd3c87b3fbc6951c87e34213086e3 Mon Sep 17 00:00:00 2001 From: Neon <71858127+yyk808@users.noreply.github.com> Date: Fri, 18 Jul 2025 19:33:53 +0800 Subject: [PATCH 10/12] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Neon <71858127+yyk808@users.noreply.github.com> --- monobean/src/core/mega_core.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/monobean/src/core/mega_core.rs b/monobean/src/core/mega_core.rs index 903bb3e20..b42a9ed81 100644 --- a/monobean/src/core/mega_core.rs +++ b/monobean/src/core/mega_core.rs @@ -502,7 +502,6 @@ mod tests { authentication: AuthConfig::default(), lfs: LFSConfig::default(), oauth: None, - //..Default::default() }; // make config saved in temp dir From 24edb0c241a885630323446b6ab051b22c6ac40c Mon Sep 17 00:00:00 2001 From: Neon <71858127+yyk808@users.noreply.github.com> Date: Fri, 18 Jul 2025 19:34:19 +0800 Subject: [PATCH 11/12] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Neon <71858127+yyk808@users.noreply.github.com> --- monobean/src/core/mega_core.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/monobean/src/core/mega_core.rs b/monobean/src/core/mega_core.rs index b42a9ed81..7d6a1eac7 100644 --- a/monobean/src/core/mega_core.rs +++ b/monobean/src/core/mega_core.rs @@ -237,7 +237,6 @@ impl MegaCore { let inner = MegaContext::mock(config.clone()).await; #[cfg(not(test))] - let inner = MegaContext::new(config.clone()).await; let http_ctx = inner.clone(); From 458f602366654adfa1d6149c1592220a752815d1 Mon Sep 17 00:00:00 2001 From: Neon <71858127+yyk808@users.noreply.github.com> Date: Fri, 18 Jul 2025 19:57:01 +0800 Subject: [PATCH 12/12] Delete monobean/resources/gschemas.compiled --- monobean/resources/gschemas.compiled | Bin 2764 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 monobean/resources/gschemas.compiled diff --git a/monobean/resources/gschemas.compiled b/monobean/resources/gschemas.compiled deleted file mode 100644 index f3a16f64796eeb072d3af3c985053c9ce0bf9b4b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2764 zcmZWqTWl0n7(Sqda&1K}MQ&TPu#24CLTe<%XhQ^wmq-+aH#$3Wx-)ckW}ORdB^XQ; z>w|#N7}BUQQId*aynvuD@>rD+!vpYwAxNSkF$6Us2CUzAW_Brbny=rt-#K$G|M|~9 z>t8Se$M7PNK26{)iO!Bsy>Z~nUv+&An>6!1I9xz@ik*;KjfLKnt)0SPJAu;nbIx=Wt!zbEDWUvS119 zxiO=GK6M@ZRp2$$XgU?*Oj_HlKa#5&G2ZzY)9zII;8PDLf}?j^71-75I7J%sBR^ zo&bLzct7C$)7wg)n(G__9|o?xy?Y&f>dEkrgTDuww*GjLKJ_&C=fJaZc>mhpb<(G1 z{|q<}oSn9!g+BFE_#I#u`1*-YPtm8I4u2PT5U`HDq4!12eGP#R19Q7hZeoAx2KXny z!$AFl=l0U4X8&{GYe4h2kM5yQ&3Oe9s}2~vIB=6b^+foM;B~+s*OpzUPtEvj1n&e6 zo%!S{eQJ(B06q;|`eN0y^r;z#3*bM2t%ZYI=u>l@cu7nG4s1TUlspz^`=zv)xYhHrz*z-v$L*5^gd_4I*v0-gT0 z$?Q+fyd40)37lJYOy6H>p8JR3L%_UiyWU}cYMnpeVW8whc3hOE>nJahj)ig+<_xRs z=+Y%bDq$uyi?xI`h;;?8i#fm&pjwBPLi543z`ijW&T)I0~%U29Nb^#xP!q^W% zq52^xV0pH3N_INnPdp5)!*ubLkfveUO0Pt(!zptTX*q!?M79%HvSI{Lzurt3^}9-L zuYS$kbVxJZ$4J;8MykwTBl=&`A<>o*^uV8hy=421IG6K_p$t^X@jcU%3g0i;rYE7V zJgee6)h{Nu9H4viH+{^DFcp12!l%%vNYA&DZ3(`Q*InN< zT-y($)hkxEwd>wGs772nA)EuUPny2xDKo;-Lhb|Q1ij;2>`2Qm8`bn2J8oNRYpWhN ze9`Tbu3suSUP-@P%vnVl^;h(Y(CS1`x8jx>)wor#$P!WszbDq>g#qHgwjYe&1Jz*`oW#soLUgfeX8A(`hNs<)iGQ?*LEaJ)~CaH`ACUwH_U7P&F_Qhc-+Tt<|BK zFhuDZg*IX^O(F@RXyKZd-RO5s_m~5AZKM5p_1{@_bEU^a(o=-sOz*mQwjWS z$g$-a%Qu&20)@L6Vn2866oc2cA==lEY1fxG4IXC1+enkNEF{0XF*VnOON{nnQb($l VimMd2)vL16cW3(R8p`;w@Bfc$KimKS