If a scheduler reply has a different master URL than the current one:

- if it's a http: to https: change, do it
- otherwise tell the user the project seems to have changed its master URL,
  and they should detach/reattach.
Remove the nonsensical "your are attached twice..." message.

Note: code you wrote a long time ago sometimes doesn't seem
to make any sense at all.
This commit is contained in:
davidpanderson 2021-10-01 21:56:14 -07:00
parent d7bdc1f04d
commit e4c6319b1c
1 changed files with 20 additions and 24 deletions

View File

@ -592,38 +592,34 @@ int CLIENT_STATE::handle_scheduler_reply(
}
}
// check that master URL is correct
// compare our URL for this project with the one returned in the reply
// (which comes from the project's config.xml).
// - if http -> https transition, make the change
// - otherwise notify the user.
// This means that if a project changes its master URL,
// its users have to detach/reattach.
//
if (strlen(sr.master_url)) {
canonicalize_master_url(sr.master_url, sizeof(sr.master_url));
string url1 = sr.master_url;
string url2 = project->master_url;
downcase_string(url1);
downcase_string(url2);
if (url1 != url2) {
p2 = lookup_project(sr.master_url);
if (p2) {
msg_printf(project, MSG_USER_ALERT,
"You are attached to this project twice. Please remove projects named %s, then add %s",
project->project_name,
sr.master_url
);
} else {
if (is_https_transition(url2.c_str(), url1.c_str())) {
strcpy(project->master_url, url1.c_str());
string reply_url = sr.master_url;
string current_url = project->master_url;
downcase_string(reply_url);
downcase_string(current_url);
if (reply_url != current_url) {
if (is_https_transition(current_url.c_str(), reply_url.c_str())) {
strcpy(project->master_url, reply_url.c_str());
project->write_account_file();
msg_printf(project, MSG_INFO,
"Project URL changed from http:// to https://"
);
} else {
msg_printf(project, MSG_USER_ALERT,
_("This project is using an old URL. When convenient, remove the project, then add %s"),
_("This project seems to have changed its URL. When convenient, remove the project, then add %s"),
sr.master_url
);
}
}
}
}
// make sure we don't already have a project of same name
//