Skip to content

Commit baa1920

Browse files
author
yujingwei
committed
feat(encryption): add kms key management
1 parent b115e22 commit baa1920

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/replica/replication_app_base.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,9 @@ error_code replica_kms_info::load_json(const std::string &fname)
170170

171171
error_code replica_kms_info::store_json(const std::string &fname)
172172
{
173-
const blob &data = json::json_forwarder<replica_kms_info>::encode(*this);
174-
std::string tmp_fname = fname + ".tmp";
175-
auto cleanup = defer([tmp_fname]() { utils::filesystem::remove_path(tmp_fname); });
176-
auto s =
177-
rocksdb::WriteStringToFile(dsn::utils::PegasusEnv(dsn::utils::FileDataType::kNonSensitive),
178-
rocksdb::Slice(data.data(), data.length()),
179-
tmp_fname,
180-
/* should_sync */ true);
181-
LOG_AND_RETURN_NOT_TRUE(
182-
ERROR, s.ok(), ERR_FILE_OPERATION_FAILED, "write file {} failed", tmp_fname);
183-
LOG_AND_RETURN_NOT_TRUE(ERROR,
184-
utils::filesystem::rename_path(tmp_fname, fname),
185-
ERR_FILE_OPERATION_FAILED,
186-
"move file from {} to {} failed",
187-
tmp_fname,
188-
fname);
189-
return ERR_OK;
173+
return write_blob_to_file(fname,
174+
json::json_forwarder<replica_kms_info>::encode(*this),
175+
dsn::utils::FileDataType::kNonSensitive);
190176
}
191177

192178
error_code replica_app_info::load(const std::string &fname)

0 commit comments

Comments
 (0)