fix: rebase conflict

This commit is contained in:
Kingtous 2022-05-13 14:46:37 +08:00
parent 8a6c3fe70a
commit c96c0df645
8 changed files with 92 additions and 38 deletions

View File

@ -1,3 +1,8 @@
use crate::log;
use directories_next::ProjectDirs;
use rand::Rng;
use serde_derive::{Deserialize, Serialize};
use sodiumoxide::crypto::sign;
use std::{
collections::HashMap,
fs,

View File

@ -230,7 +230,7 @@ pub struct TransferJobMeta {
#[serde(default)]
pub file_num: i32,
#[serde(default)]
pub is_remote: bool
pub is_remote: bool,
}
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
@ -299,11 +299,10 @@ impl TransferJob {
file_num: i32,
show_hidden: bool,
is_remote: bool,
include_hidden: bool,
enable_override_detection: bool,
) -> ResultType<Self> {
log::info!("new read {}", path);
let files = get_recursive_files(&path, include_hidden)?;
let files = get_recursive_files(&path, show_hidden)?;
let total_size = files.iter().map(|x| x.size as u64).sum();
Ok(Self {
id,
@ -597,7 +596,7 @@ impl TransferJob {
to: self.path.to_string_lossy().to_string(),
file_num: self.file_num,
show_hidden: self.show_hidden,
is_remote: self.is_remote
is_remote: self.is_remote,
}
}
}

View File

@ -535,14 +535,14 @@ impl AudioHandler {
}
self.simple = Some(Simple::new(
None, // Use the default server
&crate::get_app_name(), // Our applications name
Direction::Playback, // We want a playback stream
None, // Use the default device
"playback", // Description of our stream
&spec, // Our sample format
None, // Use default channel map
None, // Use default buffering attributes
None, // Use the default server
&crate::get_app_name(), // Our applications name
Direction::Playback, // We want a playback stream
None, // Use the default device
"playback", // Description of our stream
&spec, // Our sample format
None, // Use default channel map
None, // Use default buffering attributes
)?);
self.sample_rate = (format0.sample_rate, format0.sample_rate);
Ok(())

View File

@ -80,9 +80,10 @@ pub trait FileManager: Interface {
id: i32,
path: String,
to: String,
file_num: i32,
include_hidden: bool,
is_remote: bool,
) {
self.send(Data::SendFiles((id, path, to, include_hidden, is_remote)));
self.send(Data::SendFiles((id, path, to, file_num, include_hidden, is_remote)));
}
}

View File

@ -267,7 +267,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Account", "Аккаунт"),
("Quit", "Выйти"),
("Overwrite", "крышка"),
("This file exists, skip or overwrite this file?", "Этот файл существует, пропустить или перезаписать этот файл?")
("This file exists, skip or overwrite this file?", "Этот файл существует, пропустить или перезаписать этот файл?"),
("doc_mac_permission", "https://rustdesk.com/docs/en/manual/mac/#enable-permissions"),
("Help", "Помощь"),
].iter().cloned().collect();

View File

@ -3,9 +3,10 @@ use super::{input_service::*, *};
use crate::clipboard_file::*;
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::common::update_clipboard;
use crate::ipc;
#[cfg(any(target_os = "android", target_os = "ios"))]
use crate::{common::MOBILE_INFO2, mobile::connection_manager::start_channel};
use crate::{ipc, VERSION};
use hbb_common::fs::can_enable_overwrite_detection;
use hbb_common::log::debug;
use hbb_common::message_proto::file_transfer_send_confirm_request::Union;
use hbb_common::{
@ -974,7 +975,16 @@ impl Connection {
let id = s.id;
let od =
can_enable_overwrite_detection(get_version_number(VERSION));
match fs::TransferJob::new_read(id, s.path.clone(), s.file_num, s.include_hidden, od) {
let path = s.path.clone();
match fs::TransferJob::new_read(
id,
"".to_string(),
path.clone(),
s.file_num,
s.include_hidden,
false,
od,
) {
Err(err) => {
self.send(fs::new_error(id, err, 0)).await;
}

View File

@ -179,7 +179,7 @@ impl ConnectionManager {
..Default::default()
})
.collect(),
od,
od,
));
}
ipc::FS::CancelWrite { id } => {
@ -278,10 +278,10 @@ impl ConnectionManager {
}
}
ipc::FS::WriteOffset {
id,file_num,offset_blk
} => {
}
id,
file_num,
offset_blk,
} => {}
},
#[cfg(windows)]
Data::ClipbaordFile(_clip) => {

View File

@ -20,7 +20,6 @@ use clipboard::{
get_rx_clip_client, server_clip_file,
};
use enigo::{self, Enigo, KeyboardControllable};
use hbb_common::{config::TransferSerde, fs::TransferJobMeta};
use hbb_common::fs::{
can_enable_overwrite_detection, get_string, is_file_exists, new_send_confirm,
DigestCheckResult, RemoveJobMeta,
@ -41,6 +40,7 @@ use hbb_common::{
},
Stream,
};
use hbb_common::{config::TransferSerde, fs::TransferJobMeta};
#[cfg(windows)]
use crate::clipboard_file::*;
@ -1538,7 +1538,7 @@ impl Remote {
async fn load_last_jobs(&mut self) {
log::info!("start load last jobs");
self.handler.call("clearAllJobs",&make_args!());
self.handler.call("clearAllJobs", &make_args!());
let pc = self.handler.load_config();
if pc.transfer.write_jobs.is_empty() && pc.transfer.read_jobs.is_empty() {
// no last jobs
@ -1549,21 +1549,37 @@ impl Remote {
for job_str in pc.transfer.read_jobs.iter() {
let job: Result<TransferJobMeta, serde_json::Error> = serde_json::from_str(&job_str);
if let Ok(job) = job {
self.handler.call("addJob",&make_args!(
cnt,job.to.clone(),job.remote.clone(),job.file_num,job.show_hidden, false
));
self.handler.call(
"addJob",
&make_args!(
cnt,
job.to.clone(),
job.remote.clone(),
job.file_num,
job.show_hidden,
false
),
);
cnt += 1;
println!("restore read_job: {:?}",job);
println!("restore read_job: {:?}", job);
}
}
for job_str in pc.transfer.write_jobs.iter() {
let job: Result<TransferJobMeta, serde_json::Error> = serde_json::from_str(&job_str);
if let Ok(job) = job {
self.handler.call("addJob",&make_args!(
cnt,job.remote.clone(),job.to.clone(),job.file_num,job.show_hidden, true
));
self.handler.call(
"addJob",
&make_args!(
cnt,
job.remote.clone(),
job.to.clone(),
job.file_num,
job.show_hidden,
true
),
);
cnt += 1;
println!("restore write_job: {:?}",job);
println!("restore write_job: {:?}", job);
}
}
self.handler.call("updateTransferList", &make_args!());
@ -1586,16 +1602,35 @@ impl Remote {
Data::Message(msg) => {
allow_err!(peer.send(&msg).await);
}
Data::SendFiles((id, path, to,file_num, include_hidden, is_remote)) => {
Data::SendFiles((id, path, to, file_num, include_hidden, 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 {
log::debug!("New job {}, write to {} from remote {}", id, to, path);
self.write_jobs
.push(fs::TransferJob::new_write(id, path.clone(),to,file_num, include_hidden, is_remote, Vec::new(), od));
allow_err!(peer.send(&fs::new_send(id, path,file_num, include_hidden)).await);
self.write_jobs.push(fs::TransferJob::new_write(
id,
path.clone(),
to,
file_num,
include_hidden,
is_remote,
Vec::new(),
od,
));
allow_err!(
peer.send(&fs::new_send(id, path, file_num, include_hidden))
.await
);
} else {
match fs::TransferJob::new_read(id, to.clone(), path.clone(), file_num,include_hidden,is_remote, include_hidden, od) {
match fs::TransferJob::new_read(
id,
to.clone(),
path.clone(),
file_num,
include_hidden,
is_remote,
od,
) {
Err(err) => {
self.handle_job_status(id, -1, Some(err.to_string()));
}
@ -1927,7 +1962,7 @@ impl Remote {
}
self.handler.call("updateFolderFiles", &make_args!(m));
if let Some(job) = fs::get_job(fd.id, &mut self.write_jobs) {
log::info!("job set_files: {:?}",entries);
log::info!("job set_files: {:?}", entries);
job.set_files(entries);
} else if let Some(job) = self.remove_jobs.get_mut(&fd.id) {
job.files = entries;
@ -2032,7 +2067,11 @@ impl Remote {
}
}
Some(file_response::Union::block(block)) => {
log::info!("file response block, file id:{}, file num: {}",block.id, block.file_num);
log::info!(
"file response block, file id:{}, file num: {}",
block.id,
block.file_num
);
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