diff --git a/be/src/io/fs/local_file_system.cpp b/be/src/io/fs/local_file_system.cpp index 830a7db77cb1f8..f7ac1e77e162a7 100644 --- a/be/src/io/fs/local_file_system.cpp +++ b/be/src/io/fs/local_file_system.cpp @@ -46,6 +46,9 @@ namespace doris { namespace io { class FileReaderOptions; +std::filesystem::perms LocalFileSystem::PERMS_OWNER_RW = + std::filesystem::perms::owner_read | std::filesystem::perms::owner_write; + std::shared_ptr LocalFileSystem::create(Path path, std::string id) { return std::shared_ptr(new LocalFileSystem(std::move(path), std::move(id))); } @@ -487,5 +490,20 @@ Status LocalFileSystem::_glob(const std::string& pattern, std::vectorpermission(local_file_path, + io::LocalFileSystem::PERMS_OWNER_RW); }; RETURN_IF_ERROR(HttpClient::execute_with_retry(DOWNLOAD_FILE_MAX_RETRY, 1, download_cb)); } // Clone files from remote backend diff --git a/be/src/olap/task/engine_clone_task.cpp b/be/src/olap/task/engine_clone_task.cpp index 80d9df586408b2..7abf6fbdc4fc70 100644 --- a/be/src/olap/task/engine_clone_task.cpp +++ b/be/src/olap/task/engine_clone_task.cpp @@ -565,8 +565,8 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re << ", local_file_size=" << local_file_size; return Status::InternalError("downloaded file size is not equal"); } - chmod(local_file_path.c_str(), S_IRUSR | S_IWUSR); - return Status::OK(); + return io::global_local_filesystem()->permission(local_file_path, + io::LocalFileSystem::PERMS_OWNER_RW); }; RETURN_IF_ERROR(HttpClient::execute_with_retry(DOWNLOAD_FILE_MAX_RETRY, 1, download_cb)); } // Clone files from remote backend diff --git a/be/src/runtime/snapshot_loader.cpp b/be/src/runtime/snapshot_loader.cpp index af15371ab3c36d..c4dcc7f34def2c 100644 --- a/be/src/runtime/snapshot_loader.cpp +++ b/be/src/runtime/snapshot_loader.cpp @@ -583,8 +583,8 @@ Status SnapshotLoader::remote_http_download( << ", local_file_size=" << local_file_size; return Status::InternalError("downloaded file size is not equal"); } - chmod(local_file_path.c_str(), S_IRUSR | S_IWUSR); - return Status::OK(); + return io::global_local_filesystem()->permission( + local_file_path, io::LocalFileSystem::PERMS_OWNER_RW); }; RETURN_IF_ERROR(HttpClient::execute_with_retry(kDownloadFileMaxRetry, 1, download_cb)); diff --git a/be/src/service/backend_service.cpp b/be/src/service/backend_service.cpp index a0fa2066dfcc20..339c53cf7dd772 100644 --- a/be/src/service/backend_service.cpp +++ b/be/src/service/backend_service.cpp @@ -46,6 +46,7 @@ #include "gutil/strings/split.h" #include "gutil/strings/substitute.h" #include "http/http_client.h" +#include "io/fs/local_file_system.h" #include "olap/olap_common.h" #include "olap/olap_define.h" #include "olap/rowset/beta_rowset.h" @@ -268,8 +269,8 @@ void _ingest_binlog(IngestBinlogArg* arg) { << ", local_file_size=" << local_file_size; return Status::InternalError("downloaded file size is not equal"); } - chmod(local_segment_path.c_str(), S_IRUSR | S_IWUSR); - return Status::OK(); + return io::global_local_filesystem()->permission(local_segment_path, + io::LocalFileSystem::PERMS_OWNER_RW); }; auto status = HttpClient::execute_with_retry(max_retry, 1, get_segment_file_cb); diff --git a/be/src/service/internal_service.cpp b/be/src/service/internal_service.cpp index 7e93a84050bc09..acc2e29a3ef55e 100644 --- a/be/src/service/internal_service.cpp +++ b/be/src/service/internal_service.cpp @@ -1216,7 +1216,6 @@ void PInternalServiceImpl::hand_shake(google::protobuf::RpcController* controlle constexpr char HttpProtocol[] = "http://"; constexpr char DownloadApiPath[] = "/api/_tablet/_download?token="; constexpr char FileParam[] = "&file="; -constexpr auto Permissions = S_IRUSR | S_IWUSR; std::string construct_url(const std::string& host_port, const std::string& token, const std::string& path) { @@ -1248,8 +1247,9 @@ static Status download_file_action(std::string& remote_file_url, std::string& lo return Status::InternalError("downloaded file size is not equal"); } } - chmod(local_file_path.c_str(), Permissions); - return Status::OK(); + + return io::global_local_filesystem()->permission(local_file_path, + io::LocalFileSystem::PERMS_OWNER_RW); }; return HttpClient::execute_with_retry(DOWNLOAD_FILE_MAX_RETRY, 1, download_cb); }