Skip to content

Commit

Permalink
PR Clone fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitcoder committed Nov 22, 2024
1 parent ea77bd9 commit 6ce7e4d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hela:v8
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hela:v10
32 changes: 13 additions & 19 deletions src/utils/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,24 @@ pub async fn bulk_check_hash_exists(
mongo_uri: &str,
) -> Result<HashSet<String>, Box<dyn std::error::Error>> {
let client = connect_to_mongodb(mongo_uri, "code-security-open-source").await?;
// let existing_hashes = find_messages_in_hashes(&client, hashes).await?;
// returb blank HashSet if no hashes found
let existing_hashes = HashSet::new();
let blank_hashset = HashSet::new();
if existing_hashes.is_empty() {
return Ok(blank_hashset);
}
let existing_hashes = find_messages_in_hashes(&client, hashes).await?;
Ok(existing_hashes)
}

pub async fn register_hash(message: &str, mongo_uri: &str) {
let hashed_message = hash_text(message);
// match connect_to_mongodb(mongo_uri, "code-security-open-source").await {
// Ok(client) => {
// let collection = client
// .database("code-security-open-source")
// .collection("hashes");
// let document = doc! { "message": hashed_message };
// collection.insert_one(document, None).await.unwrap();
// }
// Err(e) => {
// print_error(&format!("Error: {}", e.to_string()), 101);
// }
// }
match connect_to_mongodb(mongo_uri, "code-security-open-source").await {
Ok(client) => {
let collection = client
.database("code-security-open-source")
.collection("hashes");
let document = doc! { "message": hashed_message };
collection.insert_one(document, None).await.unwrap();
}
Err(e) => {
print_error(&format!("Error: {}", e.to_string()), 101);
}
}
}
pub fn print_error(error: &str, error_code: i32) {
if error.to_lowercase().starts_with("warning") {
Expand Down

0 comments on commit 6ce7e4d

Please sign in to comment.