add: file_num offset
This commit is contained in:
parent
9dbd94daac
commit
a2bc2a21bb
@ -294,6 +294,7 @@ message FileTransferSendRequest {
|
||||
int32 id = 1;
|
||||
string path = 2;
|
||||
bool include_hidden = 3;
|
||||
int32 file_num = 4;
|
||||
}
|
||||
|
||||
message FileTransferSendConfirmRequest {
|
||||
@ -322,6 +323,7 @@ message FileTransferReceiveRequest {
|
||||
int32 id = 1;
|
||||
string path = 2; // path written to
|
||||
repeated FileEntry files = 3;
|
||||
int32 file_num = 4;
|
||||
}
|
||||
|
||||
message FileRemoveDir {
|
||||
|
@ -270,6 +270,7 @@ impl TransferJob {
|
||||
id: i32,
|
||||
remote: String,
|
||||
path: String,
|
||||
file_num: i32,
|
||||
show_hidden: bool,
|
||||
is_remote: bool,
|
||||
files: Vec<FileEntry>,
|
||||
@ -281,6 +282,7 @@ impl TransferJob {
|
||||
id,
|
||||
remote,
|
||||
path: get_path(&path),
|
||||
file_num,
|
||||
show_hidden,
|
||||
is_remote,
|
||||
files,
|
||||
@ -294,6 +296,7 @@ impl TransferJob {
|
||||
id: i32,
|
||||
remote: String,
|
||||
path: String,
|
||||
file_num: i32,
|
||||
show_hidden: bool,
|
||||
is_remote: bool,
|
||||
include_hidden: bool,
|
||||
@ -306,6 +309,7 @@ impl TransferJob {
|
||||
id,
|
||||
remote,
|
||||
path: get_path(&path),
|
||||
file_num,
|
||||
show_hidden,
|
||||
is_remote,
|
||||
files,
|
||||
@ -645,12 +649,13 @@ pub fn new_send_confirm(r: FileTransferSendConfirmRequest) -> Message {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new_receive(id: i32, path: String, files: Vec<FileEntry>) -> Message {
|
||||
pub fn new_receive(id: i32, path: String, file_num: i32, files: Vec<FileEntry>) -> Message {
|
||||
let mut action = FileAction::new();
|
||||
action.set_receive(FileTransferReceiveRequest {
|
||||
id,
|
||||
path,
|
||||
files: files.into(),
|
||||
file_num,
|
||||
..Default::default()
|
||||
});
|
||||
let mut msg_out = Message::new();
|
||||
@ -659,13 +664,14 @@ pub fn new_receive(id: i32, path: String, files: Vec<FileEntry>) -> Message {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new_send(id: i32, path: String, include_hidden: bool) -> Message {
|
||||
pub fn new_send(id: i32, path: String, file_num: i32, include_hidden: bool) -> Message {
|
||||
log::info!("new send: {},id : {}", path, id);
|
||||
let mut action = FileAction::new();
|
||||
action.set_send(FileTransferSendRequest {
|
||||
id,
|
||||
path,
|
||||
include_hidden,
|
||||
file_num,
|
||||
..Default::default()
|
||||
});
|
||||
let mut msg_out = Message::new();
|
||||
|
@ -1313,7 +1313,7 @@ pub enum Data {
|
||||
Close,
|
||||
Login((String, bool)),
|
||||
Message(Message),
|
||||
SendFiles((i32, String, String, bool, bool)),
|
||||
SendFiles((i32, String, String, i32, bool, bool)),
|
||||
RemoveDirAll((i32, String, bool)),
|
||||
ConfirmDeleteFiles((i32, i32)),
|
||||
SetNoConfirm(i32),
|
||||
|
@ -44,6 +44,7 @@ pub enum FS {
|
||||
NewWrite {
|
||||
path: String,
|
||||
id: i32,
|
||||
file_num: i32,
|
||||
files: Vec<(String, u64)>,
|
||||
},
|
||||
CancelWrite {
|
||||
|
@ -974,7 +974,7 @@ 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.include_hidden, od) {
|
||||
match fs::TransferJob::new_read(id, s.path.clone(), s.file_num, s.include_hidden, od) {
|
||||
Err(err) => {
|
||||
self.send(fs::new_error(id, err, 0)).await;
|
||||
}
|
||||
@ -990,6 +990,7 @@ impl Connection {
|
||||
self.send_fs(ipc::FS::NewWrite {
|
||||
path: r.path,
|
||||
id: r.id,
|
||||
file_num: r.file_num,
|
||||
files: r
|
||||
.files
|
||||
.to_vec()
|
||||
|
@ -158,14 +158,17 @@ impl ConnectionManager {
|
||||
ipc::FS::NewWrite {
|
||||
path,
|
||||
id,
|
||||
file_num,
|
||||
mut files,
|
||||
} => {
|
||||
let od = can_enable_overwrite_detection(get_version_number(VERSION));
|
||||
// cm has no show_hidden context
|
||||
// dummy remote, show_hidden, is_remote
|
||||
write_jobs.push(fs::TransferJob::new_write(
|
||||
id,
|
||||
"".to_string(),
|
||||
path,
|
||||
file_num,
|
||||
false,
|
||||
false,
|
||||
files
|
||||
|
@ -125,7 +125,7 @@ class JobTable: Reactor.Component {
|
||||
include_hidden: show_hidden,
|
||||
is_remote: is_remote });
|
||||
this.job_map[id] = this.jobs[this.jobs.length - 1];
|
||||
handler.send_files(id, path, to, show_hidden, is_remote);
|
||||
handler.send_files(id, path, to, 0, show_hidden, is_remote);
|
||||
var self = this;
|
||||
self.timer(30ms, function() { self.update(); });
|
||||
}
|
||||
@ -138,7 +138,7 @@ class JobTable: Reactor.Component {
|
||||
this.jobs.push(job);
|
||||
this.job_map[id] = this.jobs[this.jobs.length - 1];
|
||||
jobIdCounter = id + 1;
|
||||
handler.send_files(id, path, to, show_hidden, is_remote);
|
||||
handler.send_files(id, path, to, file_num, show_hidden, is_remote);
|
||||
stdout.println(JSON.stringify(job));
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ impl sciter::EventHandler for Handler {
|
||||
fn confirm_delete_files(i32, i32);
|
||||
fn set_no_confirm(i32);
|
||||
fn cancel_job(i32);
|
||||
fn send_files(i32, String, String, bool, bool);
|
||||
fn send_files(i32, String, String, i32, bool, bool);
|
||||
fn get_platform(bool);
|
||||
fn get_path_sep(bool);
|
||||
fn get_icon_path(i32, String);
|
||||
@ -1586,16 +1586,16 @@ impl Remote {
|
||||
Data::Message(msg) => {
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
Data::SendFiles((id, path, to, 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,include_hidden, is_remote, Vec::new(), od));
|
||||
allow_err!(peer.send(&fs::new_send(id, path, include_hidden)).await);
|
||||
.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, path.clone(),to.clone(),include_hidden,is_remote, include_hidden, od) {
|
||||
match fs::TransferJob::new_read(id, path.clone(),to.clone(), file_num,include_hidden,is_remote, include_hidden, od) {
|
||||
Err(err) => {
|
||||
self.handle_job_status(id, -1, Some(err.to_string()));
|
||||
}
|
||||
@ -1612,7 +1612,7 @@ impl Remote {
|
||||
let files = job.files().clone();
|
||||
self.read_jobs.push(job);
|
||||
self.timer = time::interval(MILLI1);
|
||||
allow_err!(peer.send(&fs::new_receive(id, to, files)).await);
|
||||
allow_err!(peer.send(&fs::new_receive(id, to, file_num, files)).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user