From cafd5c454569fff9fbde951e0bf2fbffcb6a13cb Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Thu, 8 Mar 2018 23:27:22 +0800 Subject: [PATCH] fix(ConfigFileUpdate): no need to create user build if shared build is up-to-date --- src/rime/lever/deployment_tasks.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/rime/lever/deployment_tasks.cc b/src/rime/lever/deployment_tasks.cc index 9b7656228..cb4b94ffc 100644 --- a/src/rime/lever/deployment_tasks.cc +++ b/src/rime/lever/deployment_tasks.cc @@ -386,16 +386,23 @@ static bool ConfigNeedsUpdate(Config* config) { "config_source_file", "", ".yaml" })); for (auto entry : *timestamps.AsMap()) { - fs::path source_file_path = resolver->ResolvePath(entry.first); - if (!fs::exists(source_file_path)) { - LOG(INFO) << "source file no longer exists: " << source_file_path.string(); - return true; - } auto value = As(entry.second); int recorded_time = 0; - if (!value || !value->GetInt(&recorded_time) || - recorded_time != (int) fs::last_write_time(source_file_path)) { - LOG(INFO) << "source file changed: " << source_file_path.string(); + if (!value || !value->GetInt(&recorded_time)) { + LOG(WARNING) << "invalid timestamp for " << entry.first; + return true; + } + fs::path source_file = resolver->ResolvePath(entry.first); + if (!fs::exists(source_file)) { + if (recorded_time) { + LOG(INFO) << "source file no longer exists: " << source_file.string(); + return true; + } + continue; + } + if (recorded_time != (int) fs::last_write_time(source_file)) { + LOG(INFO) << "source file " << (recorded_time ? "changed: " : "added: ") + << source_file.string(); return true; } }