refactor(backup): name the archive before staging verification

This commit is contained in:
Tunglies
2026-12-04 01:48:33 +08:00
parent 6b84c0d625
commit d2f0f3c0c1
2 changed files with 12 additions and 12 deletions
+5 -5
View File
@@ -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(())
}
}