From 4380016d4aa8332f560ff2d666c05a4ddd4a91e4 Mon Sep 17 00:00:00 2001 From: Xu Peng Date: Thu, 16 May 2019 11:20:10 +0800 Subject: [PATCH] fix(db): fix create directory bug in release Former-commit-id: 511730da61c4afac4b09e38aafaf77ea9617b822 --- cpp/src/db/DBMetaImpl.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cpp/src/db/DBMetaImpl.cpp b/cpp/src/db/DBMetaImpl.cpp index 3154615ed9..aaaaf21ce4 100644 --- a/cpp/src/db/DBMetaImpl.cpp +++ b/cpp/src/db/DBMetaImpl.cpp @@ -86,7 +86,11 @@ DBMetaImpl::DBMetaImpl(const DBMetaOptions& options_) Status DBMetaImpl::initialize() { if (!boost::filesystem::is_directory(_options.path)) { - assert(boost::filesystem::create_directory(_options.path)); + auto ret = boost::filesystem::create_directory(_options.path); + if (!ret) { + LOG(ERROR) << "Create directory " << _options.path << " Error"; + } + assert(ret); } ConnectorPtr = std::make_unique(StoragePrototype(_options.path+"/meta.sqlite")); @@ -123,7 +127,11 @@ Status DBMetaImpl::add_group(GroupSchema& group_info) { auto group_path = GetGroupPath(group_info.group_id); if (!boost::filesystem::is_directory(group_path)) { - assert(boost::filesystem::create_directory(group_path)); + auto ret = boost::filesystem::create_directory(group_path); + if (!ret) { + LOG(ERROR) << "Create directory " << group_path << " Error"; + } + assert(ret); } return Status::OK(); @@ -207,7 +215,11 @@ Status DBMetaImpl::add_group_file(GroupFileSchema& group_file) { auto partition_path = GetGroupDatePartitionPath(group_file.group_id, group_file.date); if (!boost::filesystem::is_directory(partition_path)) { - assert(boost::filesystem::create_directory(partition_path)); + auto ret = boost::filesystem::create_directory(partition_path); + if (!ret) { + LOG(ERROR) << "Create directory " << partition_path << " Error"; + } + assert(ret); } return Status::OK();