Skip to content

Commit

Permalink
Fix a potential race condition of MaybeCreateDirectory (#683)
Browse files Browse the repository at this point in the history
* Fix a potential race condition of MaybeCreateDirectory

---------

Co-authored-by: Qijia Liu <liumeo@pku.edu.cn>
  • Loading branch information
wengxt and eagleoflqj authored Aug 6, 2023
1 parent 7cc4e8e commit e391bc2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/rime/lever/deployment_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,16 @@ SchemaUpdate::SchemaUpdate(TaskInitializer arg) : verbose_(false) {
}

static bool MaybeCreateDirectory(fs::path dir) {
if (!fs::exists(dir)) {
boost::system::error_code ec;
if (!fs::create_directories(dir, ec)) {
LOG(ERROR) << "error creating directory '" << dir.string() << "'.";
return false;
}
boost::system::error_code ec;
if (fs::create_directories(dir, ec)) {
return true;
}
return true;

if (fs::exists(dir)) {
return true;
}
LOG(ERROR) << "error creating directory '" << dir.string() << "'.";
return false;
}

static bool RemoveVersionSuffix(string* version, const string& suffix) {
Expand Down

0 comments on commit e391bc2

Please sign in to comment.