From c5eb128cab3155f7903d6eb9fee08c91c38e6e68 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Sun, 18 May 2025 16:42:33 +0800 Subject: [PATCH] fix(clippy): skip clippy 'result_large_err' in `saturn` --- Cargo.toml | 2 +- ceres/src/api_service/import_api_service.rs | 2 +- ceres/src/pack/import_repo.rs | 6 ++-- jupiter/src/storage/git_db_storage.rs | 2 +- libra/src/internal/db.rs | 31 ++++++--------------- libra/src/internal/protocol/https_client.rs | 12 ++++---- saturn/src/context.rs | 1 + 7 files changed, 21 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0d1e60a06..9018ef159 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ git2 = "0.20.0" tempfile = "3.19.0" home = "0.5.9" ring = "0.17.8" -cedar-policy = "4.3.1" +cedar-policy = "4.4.0" secp256k1 = "0.30" pgp = "0.15" async-std = "1.13" diff --git a/ceres/src/api_service/import_api_service.rs b/ceres/src/api_service/import_api_service.rs index b9f51ba96..67907a35f 100644 --- a/ceres/src/api_service/import_api_service.rs +++ b/ceres/src/api_service/import_api_service.rs @@ -113,7 +113,7 @@ impl ApiHandler for ImportApiService { ) { let storage = self.context.services.git_db_storage.clone(); let trees = storage - .get_trees_by_hashes(self.repo.repo_id, &hashes) + .get_trees_by_hashes(self.repo.repo_id, hashes) .await .unwrap(); for tree in trees { diff --git a/ceres/src/pack/import_repo.rs b/ceres/src/pack/import_repo.rs index 8bbe58aeb..e8d02c765 100644 --- a/ceres/src/pack/import_repo.rs +++ b/ceres/src/pack/import_repo.rs @@ -204,7 +204,7 @@ impl PackHandler for ImportRepo { } } - let want_tree_ids = &want_commits.iter().map(|c| c.tree_id.to_string()).collect(); + let want_tree_ids = want_commits.iter().map(|c| c.tree_id.to_string()).collect(); let want_trees: HashMap = storage .get_trees_by_hashes(self.repo.repo_id, want_tree_ids) .await @@ -222,7 +222,7 @@ impl PackHandler for ImportRepo { let have_trees = storage .get_trees_by_hashes( self.repo.repo_id, - &have_commits.iter().map(|x| x.tree.clone()).collect(), + have_commits.iter().map(|x| x.tree.clone()).collect(), ) .await .unwrap(); @@ -266,7 +266,7 @@ impl PackHandler for ImportRepo { .context .services .git_db_storage - .get_trees_by_hashes(self.repo.repo_id, &hashes) + .get_trees_by_hashes(self.repo.repo_id, hashes) .await .unwrap() .into_iter() diff --git a/jupiter/src/storage/git_db_storage.rs b/jupiter/src/storage/git_db_storage.rs index 3f356c71b..cf2eae787 100644 --- a/jupiter/src/storage/git_db_storage.rs +++ b/jupiter/src/storage/git_db_storage.rs @@ -296,7 +296,7 @@ impl GitDbStorage { pub async fn get_trees_by_hashes( &self, repo_id: i64, - hashes: &Vec, + hashes: Vec, ) -> Result, MegaError> { Ok(git_tree::Entity::find() .filter(git_tree::Column::RepoId.eq(repo_id)) diff --git a/libra/src/internal/db.rs b/libra/src/internal/db.rs index 5b8931166..ef028651e 100644 --- a/libra/src/internal/db.rs +++ b/libra/src/internal/db.rs @@ -26,12 +26,9 @@ pub async fn establish_connection(db_path: &str) -> Result = OnceCell::const_new(); @@ -151,27 +148,17 @@ pub async fn create_database(db_path: &str) -> io::Result { )); } - std::fs::File::create(db_path).map_err(|err| { - IOError::new( - ErrorKind::Other, - format!("Failed to create database file: {:?}", err), - ) - })?; + std::fs::File::create(db_path) + .map_err(|err| IOError::other(format!("Failed to create database file: {:?}", err)))?; // Connect to the new database and set up the schema. if let Ok(conn) = establish_connection(db_path).await { - setup_database_sql(&conn).await.map_err(|err| { - IOError::new( - ErrorKind::Other, - format!("Failed to setup database: {:?}", err), - ) - })?; + setup_database_sql(&conn) + .await + .map_err(|err| IOError::other(format!("Failed to setup database: {:?}", err)))?; Ok(conn) } else { - Err(IOError::new( - ErrorKind::Other, - "Failed to connect to new database.", - )) + Err(IOError::other("Failed to connect to new database.")) } } diff --git a/libra/src/internal/protocol/https_client.rs b/libra/src/internal/protocol/https_client.rs index 2648e68f8..767843f35 100644 --- a/libra/src/internal/protocol/https_client.rs +++ b/libra/src/internal/protocol/https_client.rs @@ -223,14 +223,12 @@ impl HttpsClient { if res.status() != 200 && res.status() != 304 { tracing::error!("request failed: {:?}", res); - return Err(IoError::new( - std::io::ErrorKind::Other, - format!("Error Response format, status code: {}", res.status()), - )); + return Err(IoError::other(format!( + "Error Response format, status code: {}", + res.status() + ))); } - let result = res - .bytes_stream() - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)); + let result = res.bytes_stream().map_err(std::io::Error::other); Ok(result) } diff --git a/saturn/src/context.rs b/saturn/src/context.rs index d7143c296..14e8e9dba 100644 --- a/saturn/src/context.rs +++ b/saturn/src/context.rs @@ -42,6 +42,7 @@ pub enum Error { Request(String), } +#[allow(clippy::result_large_err)] impl CedarContext { pub fn new(entities: EntityStore) -> Result { let schema_content = include_str!("../mega.cedarschema");