Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix: fix md5 lack during block service download (#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
hycdong authored May 9, 2022
1 parent 3f0c632 commit f75c4bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/block_service/block_service_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ error_code block_service_manager::download_file(const std::string &remote_dir,
return resp.err;
}

ddebug_f(
"download file({}) succeed, file_size = {}", local_file_name.c_str(), resp.downloaded_size);
ddebug_f("download file({}) succeed, file_size = {}, md5 = {}",
local_file_name.c_str(),
resp.downloaded_size,
resp.file_md5);
download_file_size = resp.downloaded_size;
download_file_md5 = resp.file_md5;
return ERR_OK;
Expand Down
4 changes: 4 additions & 0 deletions src/block_service/fds/fds_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ dsn::task_ptr fds_file_object::download(const download_request &req,
_fds_path,
req.output_local_name);
dsn::utils::filesystem::remove_path(req.output_local_name);
} else if ((resp.err = dsn::utils::filesystem::md5sum(req.output_local_name,
resp.file_md5)) != ERR_OK) {
derror_f("download failed when calculate the md5sum of local file {}",
req.output_local_name);
}
t->enqueue_with(resp);
release_ref();
Expand Down
1 change: 1 addition & 0 deletions src/block_service/local/local_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ dsn::task_ptr local_file_object::download(const download_request &req,
target_file.c_str());
} else {
_has_meta_synced = true;
resp.file_md5 = _md5_value;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/block_service/test/fds_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ TEST_F(FDSClientTest, test_basic_operation)
->wait();
ASSERT_EQ(dsn::ERR_OK, d_resp.err);
ASSERT_EQ(cf_resp.file_handle->get_size(), d_resp.downloaded_size);
ASSERT_EQ(cf_resp.file_handle->get_md5sum(), d_resp.file_md5);
file_eq_compare(f1.filename, local_file_for_download);
}

Expand Down

0 comments on commit f75c4bb

Please sign in to comment.