mirror of
https://gitea.tendokyu.moe/beerpsi/fsdecrypt.git
synced 2026-10-01 03:08:17 +03:00
fix: set file times after writing to preserve source mtime
This commit is contained in:
+9
-6
@@ -112,6 +112,15 @@ fn extract_exfat_elements(
|
||||
let dest_path = output_dir.join(file.name());
|
||||
let mut dest = File::create(&dest_path)?;
|
||||
|
||||
{
|
||||
let mut writer = BufWriter::with_capacity(256 * 1024, &mut dest);
|
||||
std::io::copy(file, &mut writer)?;
|
||||
writer.flush()?;
|
||||
}
|
||||
pb.inc(file.len());
|
||||
|
||||
// set_times must run after writes — otherwise the kernel
|
||||
// updates mtime/atime back to "now" when bytes are flushed.
|
||||
let accessed = exfat_timestamp_to_system_time(file.timestamps().accessed());
|
||||
let modified = exfat_timestamp_to_system_time(file.timestamps().modified());
|
||||
if let (Ok(accessed), Ok(modified)) = (accessed, modified) {
|
||||
@@ -126,12 +135,6 @@ fn extract_exfat_elements(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let mut writer = BufWriter::with_capacity(256 * 1024, &mut dest);
|
||||
|
||||
std::io::copy(file, &mut writer)?;
|
||||
writer.flush()?;
|
||||
pb.inc(file.len());
|
||||
}
|
||||
FsElement::D(directory) => {
|
||||
let dest_path = output_dir.join(directory.name());
|
||||
|
||||
Reference in New Issue
Block a user