Skip to content

Commit b8175f3

Browse files
author
Bea De Presto
committed
patch v5 snapshot manifest detection
1 parent 185a3e8 commit b8175f3

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/scan.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ impl ManifestInfo {
4444
self.version = FrameworkVersion::V7;
4545
};
4646

47-
if v5_read_from_snapshot_manifest(&self.archive_dir).is_ok() {
47+
if v5_read_from_snapshot_manifest(&self.archive_dir.join("state.manifest")).is_ok()
48+
{
4849
self.version = FrameworkVersion::V5;
4950
}
5051
}
@@ -60,7 +61,7 @@ impl ManifestInfo {
6061
FrameworkVersion::Unknown
6162
}
6263
}
63-
#[derive(Clone, Debug, Default)]
64+
#[derive(Clone, Debug, Default, PartialEq)]
6465
pub enum FrameworkVersion {
6566
#[default]
6667
Unknown,
@@ -75,7 +76,7 @@ impl fmt::Display for FrameworkVersion {
7576
}
7677
}
7778

78-
#[derive(Clone, Debug, clap::ValueEnum)]
79+
#[derive(Clone, Debug, clap::ValueEnum, PartialEq)]
7980
pub enum BundleContent {
8081
Unknown,
8182
StateSnapshot,
@@ -108,20 +109,16 @@ pub fn scan_dir_archive(
108109
filename,
109110
);
110111

111-
dbg!(&pattern);
112-
113112
let mut archive = BTreeMap::new();
114113

115114
for entry in glob(&pattern)? {
116-
dbg!(&entry);
117115
match entry {
118116
Ok(manifest_path) => {
119117
let dir = manifest_path
120118
.parent()
121119
.context("no parent dir found")?
122120
.to_owned();
123121
let contents = test_content(&manifest_path);
124-
dbg!(&contents);
125122
let archive_id = dir.file_name().unwrap().to_str().unwrap().to_owned();
126123
let mut m = ManifestInfo {
127124
archive_dir: dir.clone(),

tests/test_scan_dirs.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod support;
22

33
use anyhow::Result;
4-
use libra_forensic_db::{scan::scan_dir_archive, unzip_temp::make_temp_unzipped};
4+
use libra_forensic_db::{scan::{scan_dir_archive, BundleContent, FrameworkVersion}, unzip_temp::make_temp_unzipped};
55
use support::fixtures;
66

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

1414
dbg!(&s);
15-
1615
assert!(s.0.len() == 1);
16+
let (_k, v) = s.0.first_key_value().unwrap();
17+
assert!(v.version == FrameworkVersion::V5);
18+
assert!(v.contents == BundleContent::StateSnapshot);
19+
1720
Ok(())
1821
}
22+
// #[test]
23+
24+
// fn test_scan_dir_for_v5_final() -> Result<()> {
25+
// let start_here = fixtures::v5_fixtures_path();
26+
// let s = start_here.parent().unwrap().join("v5_final_epoch/state_ver_141722729.0ab2");
27+
// let s = scan_dir_archive(&s, None)?;
28+
29+
// dbg!(&s);
30+
31+
// assert!(s.0.len() == 1);
32+
// Ok(())
33+
// }
34+
1935

2036
#[test]
2137
fn test_scan_dir_for_v7_manifests() -> Result<()> {

0 commit comments

Comments
 (0)