From 20fdcc19e65955f6f57f33497f3098aab00af34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=85=E6=88=8E=E6=B0=8F?= Date: Sun, 25 Feb 2024 17:35:21 +0800 Subject: [PATCH] fix(glog): replace deprecated API --- src/rime/lever/deployment_tasks.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/rime/lever/deployment_tasks.cc b/src/rime/lever/deployment_tasks.cc index 99ca362b9..375bfa1bd 100644 --- a/src/rime/lever/deployment_tasks.cc +++ b/src/rime/lever/deployment_tasks.cc @@ -628,14 +628,15 @@ bool CleanOldLogFiles::Run(Deployer* deployer) { string today(ymd); DLOG(INFO) << "today: " << today; + // Make sure we have sufficient permissions on the scanned directories. + // E.g. on Android, there's no write permission on the cwd. vector dirs; - // Don't call GetLoggingDirectories as it contains current directory, - // which causes permission issue on Android - // https://github.com/google/glog/blob/b58718f37cf58fa17f48bf1d576974d133d89839/src/logging.cc#L2410 - if (FLAGS_log_dir.empty()) { - google::GetExistingTempDirectories(&dirs); - } else { - dirs.push_back(FLAGS_log_dir); + for (auto& dir : google::GetLoggingDirectories()) { + auto perms = fs::status(dir).permissions(); + if ((perms & (fs::perms::owner_write | fs::perms::group_write | + fs::perms::others_write)) != fs::perms::none) { + dirs.push_back(dir); + } } DLOG(INFO) << "scanning " << dirs.size() << " temp directory for log files.";