Skip to content

Commit 960c5a8

Browse files
authored
[FIL-221] Set one approach to fetch SHA (#282)
* Set one approach to fetch SHA * Revert to correct state if sps change request exists
1 parent 09919de commit 960c5a8

File tree

2 files changed

+90
-122
lines changed

2 files changed

+90
-122
lines changed

fplus-database/src/database/applications.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::models::applications::{
55
use chrono::{DateTime, Utc};
66
use sea_orm::prelude::Expr;
77
use sea_orm::{entity::*, query::*, DbBackend, DbErr};
8-
use sha1::{Digest, Sha1};
98

109
/**
1110
* Get all applications from the database
@@ -313,7 +312,7 @@ pub async fn update_application(
313312
pr_number: u64,
314313
app_file: String,
315314
path: Option<String>,
316-
sha: Option<String>,
315+
file_sha: String,
317316
client_contract_address: Option<String>,
318317
) -> Result<ApplicationModel, sea_orm::DbErr> {
319318
let conn = get_database_connection().await?;
@@ -323,13 +322,6 @@ pub async fn update_application(
323322

324323
let mut active_application: ActiveModel = existing_application.into_active_model();
325324
active_application.application = Set(Some(app_file.clone()));
326-
let file_sha = sha.unwrap_or_else(|| {
327-
//Calculate SHA
328-
let mut hasher = Sha1::new();
329-
let application = format!("blob {}\x00{}", app_file.len(), app_file);
330-
hasher.update(application.as_bytes());
331-
format!("{:x}", hasher.finalize())
332-
});
333325
active_application.sha = Set(Some(file_sha));
334326

335327
if let Some(path) = path {
@@ -371,13 +363,9 @@ pub async fn create_application(
371363
app_file: String,
372364
path: String,
373365
issue_reporter_handle: Option<String>,
366+
file_sha: String,
374367
) -> Result<ApplicationModel, sea_orm::DbErr> {
375368
let conn = get_database_connection().await?;
376-
//Calculate SHA
377-
let mut hasher = Sha1::new();
378-
let application = format!("blob {}\x00{}", app_file.len(), app_file);
379-
hasher.update(application.as_bytes());
380-
let file_sha = format!("{:x}", hasher.finalize());
381369

382370
let new_application = ActiveModel {
383371
id: Set(id),

0 commit comments

Comments
 (0)