forked from 0LNetworkCommunity/libra-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bcb815
commit d239522
Showing
6 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod warehouse_cli; | ||
pub mod scan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//! scan | ||
use anyhow::{Context, Result}; | ||
use glob::glob; | ||
use std::{collections::BTreeMap, path::{Path, PathBuf}}; | ||
pub struct ArchiveMap(BTreeMap<PathBuf, ManifestInfo>); | ||
pub struct ManifestInfo { | ||
/// the enclosing directory of the .manifest file | ||
dir: PathBuf, | ||
/// what libra version were these files encoded with (v5 etc) | ||
version: EncodingVersion, | ||
/// contents of the manifest | ||
contents: BundleContent, | ||
/// processed | ||
processed: bool, | ||
} | ||
|
||
enum EncodingVersion { | ||
V5, | ||
V6, | ||
V7, | ||
} | ||
|
||
enum BundleContent { | ||
Snapshot, | ||
Transactions, | ||
Epoch, | ||
} | ||
|
||
/// Crawl a directory and find all .manifest files | ||
pub fn scan_dir_archive(start_dir: &Path) -> Result<ArchiveMap>{ | ||
let path = start_dir.canonicalize()?; | ||
|
||
let pattern = format!("{}/**/*.manifest", path.to_str().context("cannot parse starting dir")?); | ||
|
||
for entry in glob(&pattern).expect("Failed to read glob pattern") { | ||
match entry { | ||
Ok(path) => println!("{:?}", path.display()), | ||
Err(e) => println!("{:?}", e), | ||
} | ||
} | ||
let mut a = BTreeMap::new(); | ||
Ok(ArchiveMap(a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use anyhow::{bail, Result}; | ||
|
||
use clap::{Parser, Subcommand}; | ||
use std::{fs, path::PathBuf}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use std::path::Path; | ||
|
||
#[test] | ||
|
||
fn test_scan_dir_for_manifests() { | ||
let p = Path::from(env!("CARGO_MANIFEST_DIR")); | ||
let project_root = p.parent(); | ||
let scan_this = project_root.join("compatibility/fixtures"); | ||
|
||
let s = scan_dir_archive(scan_this); | ||
} |