Sincroniza remote_id com ID final
This commit is contained in:
parent
0120748cc5
commit
feb31d48c1
1 changed files with 24 additions and 4 deletions
|
|
@ -103,6 +103,12 @@ pub fn provision(machine_id: &str) -> Result<RustdeskProvisioningResult, Rustdes
|
||||||
fallback
|
fallback
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| custom_id.clone());
|
.unwrap_or_else(|| custom_id.clone());
|
||||||
|
if reported_id != custom_id {
|
||||||
|
log_event(&format!(
|
||||||
|
"ID retornado difere do determinístico ({custom_id}) -> aplicando {reported_id}"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
ensure_remote_id_files(&reported_id);
|
||||||
|
|
||||||
let version = query_version(&exe_path).ok().or(installed_version);
|
let version = query_version(&exe_path).ok().or(installed_version);
|
||||||
|
|
||||||
|
|
@ -207,7 +213,12 @@ fn write_file(path: &Path, contents: &str) -> Result<(), io::Error> {
|
||||||
if let Some(parent) = path.parent() {
|
if let Some(parent) = path.parent() {
|
||||||
fs::create_dir_all(parent)?;
|
fs::create_dir_all(parent)?;
|
||||||
}
|
}
|
||||||
fs::write(path, contents)
|
let mut file = OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.write(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(path)?;
|
||||||
|
file.write_all(contents.as_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn program_data_config_dir() -> PathBuf {
|
fn program_data_config_dir() -> PathBuf {
|
||||||
|
|
@ -262,7 +273,6 @@ fn set_password(exe_path: &Path) -> Result<(), RustdeskError> {
|
||||||
fn set_custom_id(exe_path: &Path, machine_id: &str) -> Result<String, RustdeskError> {
|
fn set_custom_id(exe_path: &Path, machine_id: &str) -> Result<String, RustdeskError> {
|
||||||
let custom_id = derive_numeric_id(machine_id);
|
let custom_id = derive_numeric_id(machine_id);
|
||||||
run_with_args(exe_path, &["--set-id", &custom_id])?;
|
run_with_args(exe_path, &["--set-id", &custom_id])?;
|
||||||
ensure_remote_id_files(&custom_id);
|
|
||||||
Ok(custom_id)
|
Ok(custom_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -376,9 +386,19 @@ fn write_remote_id_value(path: &Path, id: &str) -> io::Result<()> {
|
||||||
if !replaced {
|
if !replaced {
|
||||||
buffer.push_str(&replacement);
|
buffer.push_str(&replacement);
|
||||||
}
|
}
|
||||||
fs::write(path, buffer)
|
let mut file = OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.write(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(path)?;
|
||||||
|
file.write_all(buffer.as_bytes())
|
||||||
} else {
|
} else {
|
||||||
fs::write(path, replacement)
|
let mut file = OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.write(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(path)?;
|
||||||
|
file.write_all(replacement.as_bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue