feat: post file confirm and make files with the same name confirm

This commit is contained in:
Kingtous 2023-03-15 15:19:40 +08:00
parent b187d0fd59
commit b627a0d6c1
2 changed files with 9 additions and 5 deletions

View File

@ -173,7 +173,7 @@ class FfiModel with ChangeNotifier {
} else if (name == 'job_error') {
parent.target?.fileModel.jobController.jobError(evt);
} else if (name == 'override_file_confirm') {
parent.target?.fileModel.overrideFileConfirm(evt);
parent.target?.fileModel.postOverrideFileConfirm(evt);
} else if (name == 'load_last_job') {
parent.target?.fileModel.jobController.loadLastJob(evt);
} else if (name == 'update_folder_files') {

View File

@ -821,11 +821,15 @@ pub fn is_write_need_confirmation(
if path.exists() && path.is_file() {
let metadata = std::fs::metadata(path)?;
let modified_time = metadata.modified()?;
let remote_mt = Duration::from_secs(digest.last_modified);
// let remote_mt = Duration::from_secs(digest.last_modified);
let local_mt = modified_time.duration_since(UNIX_EPOCH)?;
if remote_mt == local_mt && digest.file_size == metadata.len() {
return Ok(DigestCheckResult::IsSame);
}
// [Note]
// We decide not to compare the file with peers,
// which obey the behavior of the file manager in our system.
//
// if remote_mt == local_mt && digest.file_size == metadata.len() {
// return Ok(DigestCheckResult::IsSame);
// }
Ok(DigestCheckResult::NeedConfirm(FileTransferDigest {
id: digest.id,
file_num: digest.file_num,