Skip to content

Commit 8a3e25c

Browse files
committed
fix(ConfigFileUpdate): should succeed if shared copy does not exist
1 parent cd46f7a commit 8a3e25c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/rime/lever/deployment_tasks.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,11 @@ static bool TrashCustomizedCopy(const fs::path& shared_copy,
258258
const fs::path& user_copy,
259259
const string& version_key,
260260
const fs::path& trash) {
261-
if (fs::equivalent(shared_copy, user_copy))
261+
if (!fs::exists(shared_copy) ||
262+
!fs::exists(user_copy) ||
263+
fs::equivalent(shared_copy, user_copy)) {
262264
return false;
265+
}
263266
if (IsCustomizedCopy(user_copy.string())) {
264267
string shared_copy_version;
265268
string user_copy_version;
@@ -402,19 +405,16 @@ static bool ConfigNeedsUpdate(Config* config) {
402405
bool ConfigFileUpdate::Run(Deployer* deployer) {
403406
fs::path shared_data_path(deployer->shared_data_dir);
404407
fs::path user_data_path(deployer->user_data_dir);
408+
// trash depecated user copy created by an older version of Rime
405409
fs::path source_config_path(shared_data_path / file_name_);
406410
fs::path dest_config_path(user_data_path / file_name_);
407411
fs::path trash = user_data_path / "trash";
408-
if (!fs::exists(source_config_path)) {
409-
LOG(WARNING) << "'" << file_name_
410-
<< "' is missing from shared data directory.";
411-
return false;
412-
}
413412
if (TrashCustomizedCopy(source_config_path,
414413
dest_config_path,
415414
version_key_,
416415
trash)) {
417-
LOG(INFO) << "patched copy of '" << file_name_ << "' is moved to trash.";
416+
LOG(INFO) << "deprecated user copy of '" << file_name_
417+
<< "' is moved to " << trash;
418418
}
419419
// build the config file if needs update
420420
the<Config> config(Config::Require("config")->Create(file_name_));

0 commit comments

Comments
 (0)