38
38
#include " metadata_types.h"
39
39
#include " replica/replica_base.h"
40
40
#include " replica_admin_types.h"
41
+ #include " utils/defer.h"
41
42
#include " utils/env.h"
42
43
#include " utils/error_code.h"
43
44
#include " utils/fmt_utils.h"
45
+ #include " utils/filesystem.h"
44
46
#include " utils/ports.h"
45
47
46
48
namespace dsn {
@@ -54,17 +56,18 @@ class learn_state;
54
56
class mutation ;
55
57
class replica ;
56
58
57
- namespace {
59
+ namespace {
58
60
template <class T >
59
- error_code write_blob_to_file (const std::string &fname, const T &data, const dsn::utils::FileDataType &fileDataType)
61
+ error_code write_blob_to_file (const std::string &fname,
62
+ const T &data,
63
+ const dsn::utils::FileDataType &fileDataType)
60
64
{
61
65
std::string tmp_fname = fname + " .tmp" ;
62
66
auto cleanup = defer ([tmp_fname]() { utils::filesystem::remove_path (tmp_fname); });
63
- auto s =
64
- rocksdb::WriteStringToFile (dsn::utils::PegasusEnv (fileDataType),
65
- rocksdb::Slice (data.data (), data.length ()),
66
- tmp_fname,
67
- /* should_sync */ true );
67
+ auto s = rocksdb::WriteStringToFile (dsn::utils::PegasusEnv (fileDataType),
68
+ rocksdb::Slice (data.data (), data.length ()),
69
+ tmp_fname,
70
+ /* should_sync */ true );
68
71
LOG_AND_RETURN_NOT_TRUE (
69
72
ERROR, s.ok (), ERR_FILE_OPERATION_FAILED, " write file {} failed" , tmp_fname);
70
73
LOG_AND_RETURN_NOT_TRUE (ERROR,
0 commit comments