You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by zh...@apache.org on 2019/11/12 04:47:01 UTC

[incubator-doris] branch master updated: Fix create path bug (#2177)

This is an automated email from the ASF dual-hosted git repository.

zhaoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new b9c7f6e  Fix create path bug (#2177)
b9c7f6e is described below

commit b9c7f6e5ac19ad48b511d3aa68fff731984267b3
Author: Seaven <se...@qq.com>
AuthorDate: Tue Nov 12 12:46:54 2019 +0800

    Fix create path bug (#2177)
---
 be/src/util/file_utils.cpp       | 4 ++--
 be/test/olap/file_utils_test.cpp | 7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/be/src/util/file_utils.cpp b/be/src/util/file_utils.cpp
index ce1247e..c550fac 100644
--- a/be/src/util/file_utils.cpp
+++ b/be/src/util/file_utils.cpp
@@ -52,9 +52,9 @@ Status FileUtils::create_dir(const std::string& path, Env* env) {
 
     string partial_path;
     for (boost::filesystem::path::iterator it = p.begin(); it != p.end(); ++it) {
-        partial_path = partial_path.empty() ? it->string() : partial_path + "/" + it->string();
+        partial_path = partial_path + it->string() + "/";
         bool is_dir = false;
-        
+
         Status s = env->is_directory(partial_path, &is_dir);
         
         if (s.ok()) {
diff --git a/be/test/olap/file_utils_test.cpp b/be/test/olap/file_utils_test.cpp
index 0869352..2c18f1d 100644
--- a/be/test/olap/file_utils_test.cpp
+++ b/be/test/olap/file_utils_test.cpp
@@ -190,6 +190,13 @@ TEST_F(FileUtilsTest, TestCreateDir) {
     ASSERT_TRUE(FileUtils::is_dir("./file_test/123/456/789"));
 
     FileUtils::remove_all("./file_test");
+    
+    // absolute path;
+    std::string real_path;
+    Env::Default()->canonicalize(".", &real_path);
+    ASSERT_TRUE(FileUtils::create_dir(real_path + "/file_test/absolute/path/123/asdf").ok());
+    ASSERT_TRUE(FileUtils::is_dir("./file_test/absolute/path/123/asdf"));
+    FileUtils::remove_all("./file_test");
 }
 
 TEST_F(FileUtilsTest, TestListDirsFiles) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org