From 8a3e25c9d44f756db746cb6332b008d3b61b95c8 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Tue, 20 Feb 2018 00:09:17 +0800 Subject: [PATCH] fix(ConfigFileUpdate): should succeed if shared copy does not exist --- src/rime/lever/deployment_tasks.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rime/lever/deployment_tasks.cc b/src/rime/lever/deployment_tasks.cc index 56b3a1c9f..9b7656228 100644 --- a/src/rime/lever/deployment_tasks.cc +++ b/src/rime/lever/deployment_tasks.cc @@ -258,8 +258,11 @@ static bool TrashCustomizedCopy(const fs::path& shared_copy, const fs::path& user_copy, const string& version_key, const fs::path& trash) { - if (fs::equivalent(shared_copy, user_copy)) + if (!fs::exists(shared_copy) || + !fs::exists(user_copy) || + fs::equivalent(shared_copy, user_copy)) { return false; + } if (IsCustomizedCopy(user_copy.string())) { string shared_copy_version; string user_copy_version; @@ -402,19 +405,16 @@ static bool ConfigNeedsUpdate(Config* config) { bool ConfigFileUpdate::Run(Deployer* deployer) { fs::path shared_data_path(deployer->shared_data_dir); fs::path user_data_path(deployer->user_data_dir); + // trash depecated user copy created by an older version of Rime fs::path source_config_path(shared_data_path / file_name_); fs::path dest_config_path(user_data_path / file_name_); fs::path trash = user_data_path / "trash"; - if (!fs::exists(source_config_path)) { - LOG(WARNING) << "'" << file_name_ - << "' is missing from shared data directory."; - return false; - } if (TrashCustomizedCopy(source_config_path, dest_config_path, version_key_, trash)) { - LOG(INFO) << "patched copy of '" << file_name_ << "' is moved to trash."; + LOG(INFO) << "deprecated user copy of '" << file_name_ + << "' is moved to " << trash; } // build the config file if needs update the config(Config::Require("config")->Create(file_name_));