Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ceres/src/api_service/import_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions ceres/src/pack/import_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SHA1, Tree> = storage
.get_trees_by_hashes(self.repo.repo_id, want_tree_ids)
.await
Expand All @@ -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();
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion jupiter/src/storage/git_db_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl GitDbStorage {
pub async fn get_trees_by_hashes(
&self,
repo_id: i64,
hashes: &Vec<String>,
hashes: Vec<String>,
) -> Result<Vec<git_tree::Model>, MegaError> {
Ok(git_tree::Entity::find()
.filter(git_tree::Column::RepoId.eq(repo_id))
Expand Down
31 changes: 9 additions & 22 deletions libra/src/internal/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ pub async fn establish_connection(db_path: &str) -> Result<DatabaseConnection, I

let mut option = ConnectOptions::new(format!("sqlite://{}", db_path));
option.sqlx_logging(false); // TODO use better option
Database::connect(option).await.map_err(|err| {
IOError::new(
ErrorKind::Other,
format!("Database connection error: {:?}", err),
)
})
Database::connect(option)
.await
.map_err(|err| IOError::other(format!("Database connection error: {:?}", err)))
}
// #[cfg(not(test))]
// static DB_CONN: OnceCell<DbConn> = OnceCell::const_new();
Expand Down Expand Up @@ -151,27 +148,17 @@ pub async fn create_database(db_path: &str) -> io::Result<DatabaseConnection> {
));
}

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."))
}
}

Expand Down
12 changes: 5 additions & 7 deletions libra/src/internal/protocol/https_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions saturn/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum Error {
Request(String),
}

#[allow(clippy::result_large_err)]
impl CedarContext {
pub fn new(entities: EntityStore) -> Result<Self, ContextError> {
let schema_content = include_str!("../mega.cedarschema");
Expand Down