Skip to content

Commit

Permalink
Fix create path bug (apache#2177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seaven authored and imay committed Nov 12, 2019
1 parent b4d6301 commit b9c7f6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions be/src/util/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
7 changes: 7 additions & 0 deletions be/test/olap/file_utils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b9c7f6e

Please sign in to comment.