Skip to content

Commit

Permalink
feat(encryption): add kms key management
Browse files Browse the repository at this point in the history
  • Loading branch information
yujingwei committed Dec 6, 2023
1 parent b115e22 commit baa1920
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/replica/replication_app_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,9 @@ error_code replica_kms_info::load_json(const std::string &fname)

error_code replica_kms_info::store_json(const std::string &fname)
{
const blob &data = json::json_forwarder<replica_kms_info>::encode(*this);
std::string tmp_fname = fname + ".tmp";
auto cleanup = defer([tmp_fname]() { utils::filesystem::remove_path(tmp_fname); });
auto s =
rocksdb::WriteStringToFile(dsn::utils::PegasusEnv(dsn::utils::FileDataType::kNonSensitive),
rocksdb::Slice(data.data(), data.length()),
tmp_fname,
/* should_sync */ true);
LOG_AND_RETURN_NOT_TRUE(
ERROR, s.ok(), ERR_FILE_OPERATION_FAILED, "write file {} failed", tmp_fname);
LOG_AND_RETURN_NOT_TRUE(ERROR,
utils::filesystem::rename_path(tmp_fname, fname),
ERR_FILE_OPERATION_FAILED,
"move file from {} to {} failed",
tmp_fname,
fname);
return ERR_OK;
return write_blob_to_file(fname,
json::json_forwarder<replica_kms_info>::encode(*this),
dsn::utils::FileDataType::kNonSensitive);
}

error_code replica_app_info::load(const std::string &fname)
Expand Down

0 comments on commit baa1920

Please sign in to comment.