diff --git a/src/db.cc b/src/db.cc index 02c9a8def..26decaa26 100644 --- a/src/db.cc +++ b/src/db.cc @@ -54,8 +54,9 @@ void DB::DoBgSave(const std::string& path, int i) { } void DB::CreateCheckpoint(const std::string& path) { - if (0 != pstd::CreatePath(path + '/' + std::to_string(db_index_))) { - WARN("Create dir {} fail !", path + '/' + std::to_string(db_index_)); + auto tmp_path = path + '/' + std::to_string(db_index_); + if (0 != pstd::CreatePath(tmp_path)) { + WARN("Create dir {} fail !", tmp_path); return; } checkpoint_manager_->CreateCheckpoint(path); diff --git a/src/praft/praft.cc b/src/praft/praft.cc index 3fd14fa3d..37b5e7dcf 100644 --- a/src/praft/praft.cc +++ b/src/praft/praft.cc @@ -373,6 +373,7 @@ void PRaft::AppendLog(const Binlog& log, std::promise&& promise } void PRaft::add_all_files(const std::filesystem::path& dir, braft::SnapshotWriter* writer, const std::string& path) { + assert(writer); for (const auto& entry : std::filesystem::directory_iterator(dir)) { if (entry.is_directory()) { if (entry.path() != "." && entry.path() != "..") { @@ -390,7 +391,7 @@ void PRaft::add_all_files(const std::filesystem::path& dir, braft::SnapshotWrite void PRaft::recursive_copy(const std::filesystem::path& source, const std::filesystem::path& destination) { if (std::filesystem::is_regular_file(source)) { - if (source.filename() == "__raft_snapshot_meta") { + if (source.filename() == PBRAFT_SNAPSHOT_META_FILE) { return; } else if (source.extension() == ".sst") { // Create a hard link diff --git a/src/praft/praft.h b/src/praft/praft.h index 1670b2ccf..91b392af4 100644 --- a/src/praft/praft.h +++ b/src/praft/praft.h @@ -20,6 +20,7 @@ namespace pikiwidb { #define RAFT_DBID_LEN 32 +#define PBRAFT_SNAPSHOT_META_FILE "__raft_snapshot_meta" #define PRAFT PRaft::Instance()