Check directory existence before crash.

GitOrigin-RevId: 94ad49d48af766251107b547e9ea1aaedeeb15c1
This commit is contained in:
levlam 2018-01-31 15:43:36 +03:00
parent 04e3bfaf50
commit 42ea21b4f1
2 changed files with 7 additions and 2 deletions

View File

@ -394,7 +394,12 @@ FileManager::FileManager(std::unique_ptr<Context> context) : context_(std::move(
dirs.push_back(path.str());
auto status = mkdir(path, 0750);
if (status.is_error()) {
LOG(FATAL) << "mkdir " << tag("path", path) << " failed " << status;
auto r_stat = stat(path);
if (r_stat.is_ok() && r_stat.ok().is_dir_) {
LOG(ERROR) << "mkdir " << tag("path", path) << " failed " << status << ", but directory exists";
} else {
LOG(FATAL) << "mkdir " << tag("path", path) << " failed " << status;
}
}
#if TD_ANDROID
FileFd::open(dirs.back() + ".nomedia", FileFd::Create | FileFd::Read).ignore();

View File

@ -43,7 +43,7 @@ class Parser {
void clear() {
ptr_ = nullptr;
end_ = ptr_;
status_ = Status();
status_ = Status::OK();
}
MutableSlice read_till_nofail(char c) {