Skip to content

Commit

Permalink
patch v5 snapshot manifest detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Bea De Presto committed Jan 21, 2025
1 parent 185a3e8 commit b8175f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ impl ManifestInfo {
self.version = FrameworkVersion::V7;
};

if v5_read_from_snapshot_manifest(&self.archive_dir).is_ok() {
if v5_read_from_snapshot_manifest(&self.archive_dir.join("state.manifest")).is_ok()
{
self.version = FrameworkVersion::V5;
}
}
Expand All @@ -60,7 +61,7 @@ impl ManifestInfo {
FrameworkVersion::Unknown
}
}
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub enum FrameworkVersion {
#[default]
Unknown,
Expand All @@ -75,7 +76,7 @@ impl fmt::Display for FrameworkVersion {
}
}

#[derive(Clone, Debug, clap::ValueEnum)]
#[derive(Clone, Debug, clap::ValueEnum, PartialEq)]
pub enum BundleContent {
Unknown,
StateSnapshot,
Expand Down Expand Up @@ -108,20 +109,16 @@ pub fn scan_dir_archive(
filename,
);

dbg!(&pattern);

let mut archive = BTreeMap::new();

for entry in glob(&pattern)? {
dbg!(&entry);
match entry {
Ok(manifest_path) => {
let dir = manifest_path
.parent()
.context("no parent dir found")?
.to_owned();
let contents = test_content(&manifest_path);
dbg!(&contents);
let archive_id = dir.file_name().unwrap().to_str().unwrap().to_owned();
let mut m = ManifestInfo {
archive_dir: dir.clone(),
Expand Down
20 changes: 18 additions & 2 deletions tests/test_scan_dirs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod support;

use anyhow::Result;
use libra_forensic_db::{scan::scan_dir_archive, unzip_temp::make_temp_unzipped};
use libra_forensic_db::{scan::{scan_dir_archive, BundleContent, FrameworkVersion}, unzip_temp::make_temp_unzipped};
use support::fixtures;

#[test]
Expand All @@ -12,10 +12,26 @@ fn test_scan_dir_for_v5_manifests() -> Result<()> {
let s = scan_dir_archive(&start_here, None)?;

dbg!(&s);

assert!(s.0.len() == 1);
let (_k, v) = s.0.first_key_value().unwrap();
assert!(v.version == FrameworkVersion::V5);
assert!(v.contents == BundleContent::StateSnapshot);

Ok(())
}
// #[test]

// fn test_scan_dir_for_v5_final() -> Result<()> {
// let start_here = fixtures::v5_fixtures_path();
// let s = start_here.parent().unwrap().join("v5_final_epoch/state_ver_141722729.0ab2");
// let s = scan_dir_archive(&s, None)?;

// dbg!(&s);

// assert!(s.0.len() == 1);
// Ok(())
// }


#[test]
fn test_scan_dir_for_v7_manifests() -> Result<()> {
Expand Down

0 comments on commit b8175f3

Please sign in to comment.