mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
add: overwrite version limit, remove debug log
This commit is contained in:
@@ -12,6 +12,7 @@ use hbb_common::{
|
||||
config::Config,
|
||||
fs,
|
||||
futures::{SinkExt, StreamExt},
|
||||
get_version_number,
|
||||
message_proto::{option_message::BoolOption, permission_info::Permission},
|
||||
sleep, timeout,
|
||||
tokio::{
|
||||
@@ -893,7 +894,6 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
} else if self.authorized {
|
||||
// println!("on_message: {:?}", msg);
|
||||
match msg.union {
|
||||
Some(message::Union::mouse_event(me)) => {
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
@@ -973,9 +973,9 @@ impl Connection {
|
||||
}
|
||||
Some(file_action::Union::send(s)) => {
|
||||
let id = s.id;
|
||||
let path = s.path;
|
||||
match fs::TransferJob::new_read(id, path.clone(), s.include_hidden)
|
||||
{
|
||||
let od =
|
||||
can_enable_overwrite_detection(get_version_number(VERSION));
|
||||
match fs::TransferJob::new_read(id, s.path.clone(), s.include_hidden) {
|
||||
Err(err) => {
|
||||
self.send(fs::new_error(id, err, 0)).await;
|
||||
}
|
||||
@@ -1195,7 +1195,6 @@ impl Connection {
|
||||
}
|
||||
|
||||
fn read_dir(&mut self, dir: &str, include_hidden: bool) {
|
||||
// println!("[connection.rs:1130] read_dir");
|
||||
let dir = dir.to_string();
|
||||
self.send_fs(ipc::FS::ReadDir {
|
||||
dir,
|
||||
|
||||
11
src/ui/cm.rs
11
src/ui/cm.rs
@@ -1,14 +1,17 @@
|
||||
use crate::ipc::{self, new_listener, Connection, Data};
|
||||
use crate::VERSION;
|
||||
#[cfg(windows)]
|
||||
use clipboard::{
|
||||
create_cliprdr_context, empty_clipboard, get_rx_clip_client, server_clip_file, set_conn_enabled,
|
||||
};
|
||||
use hbb_common::fs::{get_string, is_write_need_confirmation, new_send_confirm};
|
||||
use hbb_common::fs::{
|
||||
can_enable_overwrite_detection, get_string, is_write_need_confirmation, new_send_confirm,
|
||||
};
|
||||
use hbb_common::log::log;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
config::Config,
|
||||
fs, log,
|
||||
fs, get_version_number, log,
|
||||
message_proto::*,
|
||||
protobuf::Message as _,
|
||||
tokio::{self, sync::mpsc, task::spawn_blocking},
|
||||
@@ -156,6 +159,7 @@ impl ConnectionManager {
|
||||
id,
|
||||
mut files,
|
||||
} => {
|
||||
let od = can_enable_overwrite_detection(get_version_number(VERSION));
|
||||
write_jobs.push(fs::TransferJob::new_write(
|
||||
id,
|
||||
path,
|
||||
@@ -167,6 +171,7 @@ impl ConnectionManager {
|
||||
..Default::default()
|
||||
})
|
||||
.collect(),
|
||||
od,
|
||||
));
|
||||
}
|
||||
ipc::FS::CancelWrite { id } => {
|
||||
@@ -210,7 +215,7 @@ impl ConnectionManager {
|
||||
if let Some(mut digest) = digest {
|
||||
// upload to server, but server has the same file, request
|
||||
digest.is_upload = is_upload;
|
||||
println!(
|
||||
log::info!(
|
||||
"server has the same file, send server digest to local"
|
||||
);
|
||||
let mut msg_out = Message::new();
|
||||
|
||||
@@ -679,7 +679,6 @@ function confirmDelete(id ,path, is_remote) {
|
||||
}
|
||||
|
||||
handler.confirmDeleteFiles = function(id, i, name) {
|
||||
stdout.println("id=" + id +", i=" +",name="+name);
|
||||
var jt = file_transfer.job_table;
|
||||
var job = jt.job_map[id];
|
||||
if (!job) return;
|
||||
@@ -695,6 +694,7 @@ handler.confirmDeleteFiles = function(id, i, name) {
|
||||
</div>", function(res=null) {
|
||||
if (!res) {
|
||||
jt.updateJobStatus(id, i - 1, "cancel");
|
||||
file_transfer.job_table.confirmDeletePolling();
|
||||
} else if (res.skip) {
|
||||
if (res.remember){
|
||||
jt.updateJobStatus(id, i, "cancel");
|
||||
@@ -718,9 +718,6 @@ handler.confirmDeleteFiles = function(id, i, name) {
|
||||
|
||||
handler.overrideFileConfirm = function(id, file_num, to, is_upload) {
|
||||
var jt = file_transfer.job_table;
|
||||
var job = jt.job_map[id];
|
||||
stdout.println("job type: " + job.type);
|
||||
stdout.println(JSON.stringify(job));
|
||||
msgbox("custom-skip", "Confirm Write Strategy", "<div .form> \
|
||||
<div>" + translate('Overwrite') + translate('files') + ".</div> \
|
||||
<div>" + translate('This file exists, skip or overwrite this file?') + "</div> \
|
||||
|
||||
@@ -11,7 +11,9 @@ use clipboard::{
|
||||
get_rx_clip_client, server_clip_file,
|
||||
};
|
||||
use enigo::{self, Enigo, KeyboardControllable};
|
||||
use hbb_common::fs::{get_string, is_file_exists, new_send_confirm};
|
||||
use hbb_common::fs::{
|
||||
can_enable_overwrite_detection, get_string, is_file_exists, new_send_confirm,
|
||||
};
|
||||
use hbb_common::log::log;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
@@ -1537,25 +1539,27 @@ impl Remote {
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
Data::SendFiles((id, path, to, include_hidden, is_remote)) => {
|
||||
println!("send files, is remote {}", is_remote);
|
||||
log::info!("send files, is remote {}", is_remote);
|
||||
let od = can_enable_overwrite_detection(self.handler.lc.read().unwrap().version);
|
||||
if is_remote {
|
||||
println!("New job {}, write to {} from remote {}", id, to, path);
|
||||
log::debug!("New job {}, write to {} from remote {}", id, to, path);
|
||||
self.write_jobs
|
||||
.push(fs::TransferJob::new_write(id, to, Vec::new()));
|
||||
.push(fs::TransferJob::new_write(id, to, Vec::new(), od));
|
||||
allow_err!(peer.send(&fs::new_send(id, path, include_hidden)).await);
|
||||
} else {
|
||||
match fs::TransferJob::new_read(id, path.clone(), include_hidden) {
|
||||
match fs::TransferJob::new_read(id, path.clone(), include_hidden, od) {
|
||||
Err(err) => {
|
||||
self.handle_job_status(id, -1, Some(err.to_string()));
|
||||
}
|
||||
Ok(job) => {
|
||||
println!(
|
||||
log::debug!(
|
||||
"New job {}, read {} to remote {}, {} files",
|
||||
id,
|
||||
path,
|
||||
to,
|
||||
job.files().len()
|
||||
);
|
||||
let config = self.handler.lc.read().unwrap().version;
|
||||
let m = make_fd(job.id(), job.files(), true);
|
||||
self.handler.call("updateFolderFiles", &make_args!(m));
|
||||
let files = job.files().clone();
|
||||
@@ -1780,7 +1784,6 @@ impl Remote {
|
||||
|
||||
async fn handle_msg_from_peer(&mut self, data: &[u8], peer: &mut Stream) -> bool {
|
||||
if let Ok(msg_in) = Message::parse_from_bytes(&data) {
|
||||
// println!("recved msg from peer, decoded: {:?}", msg_in);
|
||||
match msg_in.union {
|
||||
Some(message::Union::video_frame(vf)) => {
|
||||
if !self.first_frame {
|
||||
@@ -1928,13 +1931,11 @@ impl Remote {
|
||||
if let Some(job) = fs::get_job(block.id, &mut self.write_jobs) {
|
||||
if let Err(_err) = job.write(block, None).await {
|
||||
// to-do: add "skip" for writing job
|
||||
println!("error: {}", _err);
|
||||
}
|
||||
self.update_jobs_status();
|
||||
}
|
||||
}
|
||||
Some(file_response::Union::done(d)) => {
|
||||
log::info!("file response done");
|
||||
if let Some(job) = fs::get_job(d.id, &mut self.write_jobs) {
|
||||
job.modify_time();
|
||||
fs::remove_job(d.id, &mut self.write_jobs);
|
||||
|
||||
Reference in New Issue
Block a user