Skip to content

Commit

Permalink
fix(ConfigFileUpdate): should succeed if shared copy does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Feb 19, 2018
1 parent cd46f7a commit 8a3e25c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/rime/lever/deployment_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(Config::Require("config")->Create(file_name_));
Expand Down

0 comments on commit 8a3e25c

Please sign in to comment.