mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-05 05:50:04 +08:00
refactor(backup): name the archive before staging verification
This commit is contained in:
@@ -35,12 +35,12 @@ impl<W: Write + Seek> BackupWriter<W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ValidatedBackup<R: Read + Seek> {
|
||||
pub struct BackupArchive<R: Read + Seek> {
|
||||
zip: ZipArchive<R>,
|
||||
}
|
||||
|
||||
impl<R: Read + Seek> ValidatedBackup<R> {
|
||||
/// Checks the archive layout. Extract into staging to validate file contents before restore.
|
||||
impl<R: Read + Seek> BackupArchive<R> {
|
||||
/// Checks entry paths and lengths. Extract into staging to verify stored file checksums 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() {
|
||||
@@ -98,7 +98,7 @@ mod tests {
|
||||
bytes[22..26].copy_from_slice(&4u32.to_le_bytes());
|
||||
bytes[directory + 24..directory + 28].copy_from_slice(&4u32.to_le_bytes());
|
||||
assert!(
|
||||
ValidatedBackup::open(Cursor::new(bytes), &[]).is_err(),
|
||||
BackupArchive::open(Cursor::new(bytes), &[]).is_err(),
|
||||
"{name} {method:?}"
|
||||
);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ mod tests {
|
||||
let index = zip.by_index(2)?;
|
||||
assert_eq!(index.name()?, "profiles.yaml");
|
||||
assert_eq!(index.last_modified(), profile_time);
|
||||
ValidatedBackup::open(source, &[".profile-refresh", ".profile-refresh.lock"])?;
|
||||
BackupArchive::open(source, &[".profile-refresh", ".profile-refresh.lock"])?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user