feat:Streaming file transfer

Signed-off-by: m30058418 <maliang87@huawei.com>
This commit is contained in:
m30058418 2024-06-26 14:08:59 +08:00
parent a02123a901
commit 491809834b
2 changed files with 5 additions and 4 deletions

View File

@ -68,8 +68,8 @@ impl FileManager {
0
}
};
if meta_size == KERNEL_FILE_NODE_SIZE.into() {
let node_size = self.buffer_read() as u64;
if meta_size == KERNEL_FILE_NODE_SIZE.into() || meta_size == 0 {
let node_size = self.buffer_read(meta_size) as u64;
return node_size;
} else {
return meta_size;
@ -78,7 +78,7 @@ impl FileManager {
0
}
pub fn buffer_read(&self) -> usize {
pub fn buffer_read(&self, meta_size: u64) -> usize {
let mut buf = [0u8; KERNEL_FILE_NODE_SIZE as usize];
let mut read_len = 0usize;
if let Some(path) = &self.path {
@ -96,7 +96,7 @@ impl FileManager {
}
};
read_len += single_len;
if single_len == 0 {
if single_len == 0 || meta_size == 0 {
break;
}
}

View File

@ -54,6 +54,7 @@ def test_small_file():
def test_node_file():
assert check_hdc_cmd(f"file recv {get_remote_path('../../../sys/power/state')} {get_local_path('state')}")
assert check_hdc_cmd(f"file recv {get_remote_path('../../../sys/firmware/fdt')} {get_local_path('fdt')}")
assert check_hdc_cmd(f"file recv {get_remote_path('../../../proc/cpuinfo')} {get_local_path('cpuinfo')}")
@pytest.mark.repeat(1)