From 2f29dda5aa5ef236910541b351fda5d35e2463c7 Mon Sep 17 00:00:00 2001 From: abmdocrt Date: Fri, 29 Dec 2023 09:07:59 +0800 Subject: [PATCH] [Fix](core) Fix file system scan deleted file (#29266) --- be/src/io/fs/local_file_system.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/be/src/io/fs/local_file_system.cpp b/be/src/io/fs/local_file_system.cpp index d7e1372ffe..78ba222d1f 100644 --- a/be/src/io/fs/local_file_system.cpp +++ b/be/src/io/fs/local_file_system.cpp @@ -32,6 +32,7 @@ #include #include +#include "common/exception.h" #include "gutil/macros.h" #include "io/fs/err_utils.h" #include "io/fs/file_system.h" @@ -182,7 +183,11 @@ Status LocalFileSystem::directory_size(const Path& dir_path, size_t* dir_size) { if (std::filesystem::exists(dir_path) && std::filesystem::is_directory(dir_path)) { for (const auto& entry : std::filesystem::recursive_directory_iterator(dir_path)) { if (std::filesystem::is_regular_file(entry)) { - *dir_size += std::filesystem::file_size(entry); + try { + *dir_size += std::filesystem::file_size(entry); + } catch (const std::exception& e) { + LOG(INFO) << "{}", e.what(); + } } } return Status::OK();