mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-08-16 00:25:39 +00:00
Merge pull request #323 from fufesou/feat/file_transfer_digest_is_resume
feat: file transfer, digest flag, is_resume
This commit is contained in:
commit
024380d0f9
@ -437,7 +437,11 @@ message FileTransferDigest {
|
|||||||
uint64 file_size = 4;
|
uint64 file_size = 4;
|
||||||
bool is_upload = 5;
|
bool is_upload = 5;
|
||||||
bool is_identical = 6;
|
bool is_identical = 6;
|
||||||
uint64 transferred_size = 7; // for resume transfer, indicates the size of the file already transferred
|
uint64 transferred_size = 7; // For resume. Indicates the size of the file already transferred
|
||||||
|
bool is_resume = 8; // For resume. Indicates if the transfer is a resume.
|
||||||
|
// `is_resume` can let the controlled side know whether to check the `.digest` file.
|
||||||
|
// When `is_resume` is false, `.digest` exists, the same file does not exist,
|
||||||
|
// the controlled side should not check `.digest`, it should confirm with a new transfer request.
|
||||||
}
|
}
|
||||||
|
|
||||||
message FileTransferBlock {
|
message FileTransferBlock {
|
||||||
|
@ -806,6 +806,7 @@ impl TransferJob {
|
|||||||
file_num: self.file_num,
|
file_num: self.file_num,
|
||||||
last_modified,
|
last_modified,
|
||||||
file_size: meta.len(),
|
file_size: meta.len(),
|
||||||
|
is_resume: self.is_resume,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
msg.set_file_response(resp);
|
msg.set_file_response(resp);
|
||||||
@ -1203,14 +1204,14 @@ pub enum DigestCheckResult {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_write_need_confirmation(
|
pub fn is_write_need_confirmation(
|
||||||
is_support_resume: bool,
|
is_resume: bool,
|
||||||
file_path: &str,
|
file_path: &str,
|
||||||
digest: &FileTransferDigest,
|
digest: &FileTransferDigest,
|
||||||
) -> ResultType<DigestCheckResult> {
|
) -> ResultType<DigestCheckResult> {
|
||||||
let path = Path::new(file_path);
|
let path = Path::new(file_path);
|
||||||
let digest_file = format!("{}.digest", file_path);
|
let digest_file = format!("{}.digest", file_path);
|
||||||
let download_file = format!("{}.download", file_path);
|
let download_file = format!("{}.download", file_path);
|
||||||
if is_support_resume && Path::new(&digest_file).exists() && Path::new(&download_file).exists() {
|
if is_resume && Path::new(&digest_file).exists() && Path::new(&download_file).exists() {
|
||||||
// If the digest file exists, it means the file was transferred before.
|
// If the digest file exists, it means the file was transferred before.
|
||||||
// We can use the digest file to check whether the file is the same.
|
// We can use the digest file to check whether the file is the same.
|
||||||
if let Ok(content) = std::fs::read_to_string(digest_file) {
|
if let Ok(content) = std::fs::read_to_string(digest_file) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user