Skip to content

Commit 29acd08

Browse files
committed
fix
1 parent b91ee27 commit 29acd08

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/paimon/fs/local/local_file.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,8 @@ Result<bool> LocalFile::Mkdir() const {
151151
dir.resize(len - 1);
152152
}
153153
}
154-
size_t pos = dir.rfind('/');
155-
if (pos == std::string::npos) {
156-
return mkdir(dir.c_str(), 0755) == 0;
157-
}
158-
std::string parent_dir = dir.substr(0, pos);
159-
if (!parent_dir.empty() && access(parent_dir.c_str(), F_OK) != 0) {
160-
PAIMON_RETURN_NOT_OK(MkNestDir(parent_dir));
161-
}
162-
return mkdir(dir.c_str(), 0755) == 0;
154+
PAIMON_ASSIGN_OR_RAISE(bool success, MkNestDir(dir));
155+
return success;
163156
}
164157

165158
Result<std::unique_ptr<LocalFileStatus>> LocalFile::GetFileStatus() const {

src/paimon/fs/local/local_file_system.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Status LocalFileSystem::Mkdirs(const std::string& path) const {
7676
}
7777

7878
Status LocalFileSystem::MkdirsInternal(const LocalFile& file) const {
79-
// Important: The 'Exists()' check above must come before the 'IsDirectory()'
79+
// Important: The 'Exists()' check above must come before the 'IsDir()'
8080
// check to be safe when multiple parallel instances try to create the directory
8181
PAIMON_ASSIGN_OR_RAISE(bool is_exist, file.Exists());
8282
if (is_exist) {
@@ -90,6 +90,10 @@ Status LocalFileSystem::MkdirsInternal(const LocalFile& file) const {
9090
}
9191
}
9292

93+
auto parent = file.GetParentFile();
94+
if (!parent.IsEmpty()) {
95+
PAIMON_RETURN_NOT_OK(MkdirsInternal(parent));
96+
}
9397
PAIMON_ASSIGN_OR_RAISE(bool success, file.Mkdir());
9498
if (!success) {
9599
PAIMON_ASSIGN_OR_RAISE(bool is_dir, file.IsDir());

0 commit comments

Comments
 (0)