@@ -118,7 +118,7 @@ crust_status_t storage_seal_file(const char *p_tree, size_t tree_len, const char
118118 wl->add_new_file (file_entry_json);
119119
120120 // Add info in workload spec
121- wl->set_wl_spec (WL_SPEC_FILE_UNCONFIRMED_SIZE, file_entry_json[FILE_SIZE ].ToInt ());
121+ wl->set_wl_spec (WL_SPEC_FILE_UNCONFIRMED_SIZE, file_entry_json[FILE_OLD_SIZE ].ToInt ());
122122
123123 return crust_status;
124124}
@@ -482,7 +482,7 @@ crust_status_t storage_confirm_file(const char *hash)
482482 // Set workload spec information
483483 if (is_confirmed)
484484 {
485- wl->set_wl_spec (WL_SPEC_FILE_VALID_SIZE, WL_SPEC_FILE_UNCONFIRMED_SIZE, confirmed_file[FILE_SIZE ].ToInt ());
485+ wl->set_wl_spec (WL_SPEC_FILE_VALID_SIZE, WL_SPEC_FILE_UNCONFIRMED_SIZE, confirmed_file[FILE_OLD_SIZE ].ToInt ());
486486 }
487487
488488 return crust_status;
@@ -496,7 +496,7 @@ crust_status_t storage_confirm_file(const char *hash)
496496crust_status_t storage_delete_file (const char *hash)
497497{
498498 // ----- Delete file items in metadata ----- //
499- std::string deleted_file;
499+ json::JSON deleted_file;
500500 crust_status_t crust_status = CRUST_SUCCESS;
501501
502502 // ----- Delete file items in checked_files ----- //
@@ -508,8 +508,8 @@ crust_status_t storage_delete_file(const char *hash)
508508 std::string hash_str = wl->checked_files [i][FILE_HASH].ToString ();
509509 if (hash_str.compare (hash) == 0 )
510510 {
511+ deleted_file = wl->checked_files [i];
511512 wl->checked_files [i][FILE_STATUS].set_char (CURRENT_STATUS, FILE_STATUS_DELETED);
512- deleted_file = hash_str;
513513 is_deleted = true ;
514514 break ;
515515 }
@@ -523,7 +523,7 @@ crust_status_t storage_delete_file(const char *hash)
523523 std::string hash_str = (*it)[FILE_HASH].ToString ();
524524 if (hash_str.compare (hash) == 0 )
525525 {
526- deleted_file = hash_str ;
526+ deleted_file = *it ;
527527 wl->new_files .erase ((++it).base ());
528528 is_deleted = true ;
529529 break ;
@@ -535,20 +535,24 @@ crust_status_t storage_delete_file(const char *hash)
535535 // Print deleted info
536536 if (is_deleted)
537537 {
538- log_info (" Delete file:%s successfully!\n " , deleted_file.c_str ());
538+ log_info (" Delete file:%s successfully!\n " , deleted_file[FILE_HASH]. ToString () .c_str ());
539539 }
540540 else
541541 {
542- log_warn (" Delete file:%s failed(not found)!\n " , deleted_file.c_str ());
542+ log_warn (" Delete file:%s failed(not found)!\n " , deleted_file[FILE_HASH]. ToString () .c_str ());
543543 }
544544
545545 // ----- Delete file related data ----- //
546546 if (is_deleted)
547547 {
548548 // Delete file tree structure
549- persist_del (deleted_file);
549+ persist_del (deleted_file[FILE_HASH]. ToString () );
550550 // Delete file metadata
551- persist_del (deleted_file + " _meta" );
551+ persist_del (deleted_file[FILE_HASH].ToString () + " _meta" );
552+ // Update workload spec info
553+ std::pair<wl_spec_t , wl_spec_t > wl_p;
554+ wl->get_wl_spec_by_file_status (deleted_file[FILE_STATUS].get_char (CURRENT_STATUS), wl_p);
555+ wl->set_wl_spec (wl_p.second , -deleted_file[FILE_OLD_SIZE].ToInt ());
552556 }
553557
554558 return crust_status;
0 commit comments