Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deployer): allow disabling backup_config_files #991

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rime/deployer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Deployer::Deployer()
prebuilt_data_dir("build"),
staging_dir("build"),
sync_dir("sync"),
user_id("unknown") {}
user_id("unknown"),
backup_config_files(true) {}

Deployer::~Deployer() {
JoinWorkThread();
Expand Down
1 change: 1 addition & 0 deletions src/rime/deployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Deployer : public Messenger {
string distribution_code_name;
string distribution_version;
string app_name;
bool backup_config_files;
// }

RIME_DLL Deployer();
Expand Down
8 changes: 8 additions & 0 deletions src/rime/lever/deployment_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ bool InstallationUpdate::Run(Deployer* deployer) {
deployer->sync_dir = user_data_path / "sync";
}
LOG(INFO) << "sync dir: " << deployer->sync_dir;
bool backup_config_files;
if (config.GetBool("backup_config_files", &backup_config_files)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.GetBool("backup_config_files", &deployer->backup_config_files);

這樣應該等效,不過我不反對寫清楚點兒。

deployer->backup_config_files = backup_config_files;
}
if (config.GetString("distribution_code_name", &last_distro_code_name)) {
LOG(INFO) << "previous distribution: " << last_distro_code_name;
}
Expand Down Expand Up @@ -535,6 +539,10 @@ static bool IsCustomizedCopy(const path& file_path) {
}

bool BackupConfigFiles::Run(Deployer* deployer) {
if (!deployer->backup_config_files) {
LOG(INFO) << "skip backing up config files because it's disabled.";
return true;
}
LOG(INFO) << "backing up config files.";
const path user_data_path(deployer->user_data_dir);
if (!fs::exists(user_data_path))
Expand Down
Loading