Refactor and reorganize the file utils (#2089)

This commit is contained in:
Seaven
2019-11-11 20:25:41 +08:00
committed by ZHAO Chun
parent 068eed8eb0
commit d0316d158d
27 changed files with 581 additions and 475 deletions

View File

@ -690,7 +690,7 @@ void StorageEngine::_clean_unused_txns() {
OLAPStatus StorageEngine::_do_sweep(
const string& scan_root, const time_t& local_now, const int32_t expire) {
OLAPStatus res = OLAP_SUCCESS;
if (!check_dir_existed(scan_root)) {
if (!FileUtils::check_exist(scan_root)) {
// dir not existed. no need to sweep trash.
return res;
}
@ -720,8 +720,10 @@ OLAPStatus StorageEngine::_do_sweep(
VLOG(10) << "get actual expire time " << actual_expire << " of dir: " << dir_name;
if (difftime(local_now, mktime(&local_tm_create)) >= actual_expire) {
if (remove_all_dir(path_name) != OLAP_SUCCESS) {
LOG(WARNING) << "fail to remove file or directory. path=" << path_name;
Status ret = FileUtils::remove_all(path_name);
if (!ret.ok()) {
LOG(WARNING) << "fail to remove file or directory. path=" << path_name
<< ", error=" << ret.to_string();
res = OLAP_ERR_OS_ERROR;
continue;
}