@@ -5,7 +5,6 @@ use crate::models::applications::{
5
5
use chrono:: { DateTime , Utc } ;
6
6
use sea_orm:: prelude:: Expr ;
7
7
use sea_orm:: { entity:: * , query:: * , DbBackend , DbErr } ;
8
- use sha1:: { Digest , Sha1 } ;
9
8
10
9
/**
11
10
* Get all applications from the database
@@ -313,7 +312,7 @@ pub async fn update_application(
313
312
pr_number : u64 ,
314
313
app_file : String ,
315
314
path : Option < String > ,
316
- sha : Option < String > ,
315
+ file_sha : String ,
317
316
client_contract_address : Option < String > ,
318
317
) -> Result < ApplicationModel , sea_orm:: DbErr > {
319
318
let conn = get_database_connection ( ) . await ?;
@@ -323,13 +322,6 @@ pub async fn update_application(
323
322
324
323
let mut active_application: ActiveModel = existing_application. into_active_model ( ) ;
325
324
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
- } ) ;
333
325
active_application. sha = Set ( Some ( file_sha) ) ;
334
326
335
327
if let Some ( path) = path {
@@ -371,13 +363,9 @@ pub async fn create_application(
371
363
app_file : String ,
372
364
path : String ,
373
365
issue_reporter_handle : Option < String > ,
366
+ file_sha : String ,
374
367
) -> Result < ApplicationModel , sea_orm:: DbErr > {
375
368
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( ) ) ;
381
369
382
370
let new_application = ActiveModel {
383
371
id : Set ( id) ,
0 commit comments