mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-03 04:00:23 +08:00
perf(backup): verify file contents during restore staging
This commit is contained in:
@@ -40,6 +40,7 @@ pub struct ValidatedBackup<R: Read + Seek> {
|
||||
}
|
||||
|
||||
impl<R: Read + Seek> ValidatedBackup<R> {
|
||||
/// Checks the archive layout. Extract into staging to validate file contents before restore.
|
||||
pub fn open(source: R, reserved_names: &[&str]) -> Result<Self, ArchiveError> {
|
||||
let mut zip = ZipArchive::new(source)?;
|
||||
for index in 0..zip.len() {
|
||||
@@ -60,7 +61,10 @@ impl<R: Read + Seek> ValidatedBackup<R> {
|
||||
return Err(ArchiveError::ReservedEntry);
|
||||
}
|
||||
}
|
||||
io::copy(&mut entry, &mut io::sink())?;
|
||||
// ZIP extraction skips directory payloads.
|
||||
if entry.is_dir() {
|
||||
io::copy(&mut entry, &mut io::sink())?;
|
||||
}
|
||||
}
|
||||
Ok(Self { zip })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user