implement list_files_recursion for calibrate disk space in shared-storage mode

This commit is contained in:
Revendell
2024-10-15 14:44:16 +00:00
committed by ob-robot
parent 01e0e0ead9
commit a4f4c1b5f2
3 changed files with 129 additions and 5 deletions

View File

@ -15,6 +15,8 @@
#include "lib/ob_define.h"
#include "lib/allocator/ob_malloc.h"
#include "lib/ob_errno.h"
#include "common/ob_smart_call.h"
#include "lib/utility/ob_hang_fatal_error.h"
#include <stdlib.h>
#include <stdio.h>
@ -415,7 +417,7 @@ int FileDirectoryUtils::delete_directory_rec(const char *path)
{
int ret = OB_SUCCESS;
DIR *dir = NULL;
struct dirent *entry;
struct dirent *entry = nullptr;
if (NULL == (dir = opendir(path))) {
if (ENOENT != errno) {
ret = OB_FILE_NOT_OPENED;
@ -437,7 +439,7 @@ int FileDirectoryUtils::delete_directory_rec(const char *path)
} else if (OB_FAIL(FileDirectoryUtils::is_directory(current_file_path, is_dir))) {
LIB_LOG(WARN, "is_directory failed", K(ret), K(entry->d_name));
// delecte directory recursive
} else if (true == is_dir && OB_FAIL(delete_directory_rec(current_file_path))) {
} else if (true == is_dir && OB_FAIL(SMART_CALL(delete_directory_rec(current_file_path)))) {
LIB_LOG(WARN, "delete directory failed", K(ret), K(entry->d_name), K(path));
// delete normal file
} else if (false == is_dir && OB_FAIL(FileDirectoryUtils::delete_file(current_file_path))) {
@ -452,6 +454,7 @@ int FileDirectoryUtils::delete_directory_rec(const char *path)
}
if (NULL != dir) {
closedir(dir);
dir = nullptr;
}
return ret;
}
@ -460,7 +463,7 @@ int FileDirectoryUtils::delete_tmp_file_or_directory_at(const char *path)
{
int ret = OB_SUCCESS;
DIR *dir = NULL;
struct dirent *entry;
struct dirent *entry = nullptr;
if (NULL == (dir = opendir(path))) {
ret = OB_ERR_SYS;
LIB_LOG(WARN, "opendir failed", K(path));